Display set of names in array when we press the first letter

Ads

 
 

Share on Google+Share on Google+

Lakshmi
Display set of names in array when we press the first letter
2 Answer(s)      5 years and 8 months ago
Posted in : Java Beginners

Please help to write a program which have to display set of names in the array when we click the starting letter (like in gmail if we press the letter it will show the available names)using java

Ads
View Answers

February 11, 2012 at 11:51 AM




February 11, 2012 at 12:13 PM


import java.util.*;

class DisplaySetOfNames{
    public static void main(String[] args) 
    {
        String[] countries = {"Afghanistan", "Albania", "Algeria", "Andorra", "Angola","Argentina"
,"Armenia","Austria","Bahamas","Bahrain", "Bangladesh","Barbados", "Belarus","Belgium",
"Benin","Bhutan","Bolivia","Bosnia & Herzegovina","Botswana","Brazil","Bulgaria",
"Burkina Faso","Burma","Burundi","Cambodia","Cameroon","Canada", "China","Colombia",
"Comoros","Congo","Croatia","Cuba","Cyprus","Czech Republic","Denmark", "Georgia",
"Germany","Ghana","Great Britain","Greece","Hungary","Holland","India","Iran","Iraq",
"Italy","Somalia", "Spain", "Sri Lanka", "Sudan","Suriname", "Swaziland","Sweden",
"Switzerland", "Syria","Uganda","Ukraine","United Arab Emirates","United Kingdom",
"United States","Uruguay","Uzbekistan","Vanuatu","Venezuela","Vietnam",
"Yemen","Zaire","Zambia","Zimbabwe"};
        Scanner input=new Scanner(System.in);
        System.out.print("Enter letter: ");
        String letter=input.next().substring(0,1);
        System.out.println();
        for(int i=0;i<countries.length;i++){
            if(countries[i].startsWith(letter)){
                System.out.println(countries[i]);
            }
        }
    }
}

Ads









Related Tutorials/Questions & Answers:
Display set of names in array when we press the first letter
Display set of names in array when we press the first letter  Please help to write a program which have to display set of names in the array when we click the starting letter (like in gmail if we press the letter it will show
display a list of names(when we press first letter)
display a list of names(when we press first letter)  If i gave...("Enter letter: "); String letter=input.next().substring(0,1...++){ if(countries[i].startsWith(letter)){ System.out.println(countries
Advertisements
Display set of names from array
Display set of names from array In this section, you will learn how to display the set of names from array. In the given code, we have declared an array... element, it will display the set of countries name from the array. Example
Display set names
Display set names  If i enter the First letter of a name it will display the list of names starting with that letter in command prompt using java...); System.out.print("Enter letter: "); String letter=input.next
Display first letter of every word in uppercase
Display first letter of every word in upper case In this Java tutorial section, you will learn how to display the first letter of every word in uppercase. For this, we have allowed the user to enter the string. The BufferedReader class
display all words containing the letter which i gave as input...
display all words containing the letter which i gave as input...  If i enter any character,it have to display the names which having that character..write a program using java example(output) Enter any character: a Names: Abi
JavaScript array first element
JavaScript array first element  ... a code that makes you easy to understand in array first element example... invokes a function display. This function  include a variable array that is used
should not go back to index.jsp when press on the link logout
should not go back to index.jsp when press on the link logout  Hello... when i click on this link then it will move to the another page i.e. Logout.java.but now the problem is this ,when i press the back arrow on the browser
should not go back to index.jsp when press on the link logout
should not go back to index.jsp when press on the link logout  Hello... when i click on this link then it will move to the another page i.e. Logout.java.but now the problem is this ,when i press the back arrow on the browser
should not go back to index.jsp when press on the link logout
should not go back to index.jsp when press on the link logout  Hello... when i click on this link then it will move to the another page i.e. Logout.java.but now the problem is this ,when i press the back arrow on the browser
How to load elements from db when i press next.
How to load elements from db when i press next.  Hello , I am working on a project "Online Book Mart" using JSP and Servlets and I am astuck... means when i click next, the next 20 books will be displayed from db on the same
print selected checkbox names in array without form tag
print selected checkbox names in array without form tag  Hi everyone...;% %> [/code] so, i want to display all seleced checked checkbox names, when i click on button but without using FORM tag
getting an error when set classpath
getting an error when set classpath  Hello Everyone! i have used hssf model for reading excel sheet in my project & i have set classpath for that jar file but when i compile the program it will compile correctly but when i
When were generics first introduced in Java?
When were generics first introduced in Java?  Hi, I want to know when were generics first introduced in java?   Generics were introduced to the Java programming language with the release of Java 5.0 in 2014. Check
The query used to display all tables names in SQL Server.
The query used to display all tables names in SQL Server.  What is the query used to display all tables names in SQL Server (Query analyzer
program to display the first ten terms of the series
program to display the first ten terms of the series  Write a program to display the first ten terms of the following series : 1) 1,-3,5,-7,9..... 2) 3,6,12,24..... 3) 2,5,10,17....... 4) 0,1,2,3,6............ 5) 0,3,8,15
To find first two maximum numbers in an array
To find first two maximum numbers in an array  Java program to find first two maximum numbers in an array,using single loop without sorting array
What is the first argument of the String array in main() method?
What is the first argument of the String array in main() method?  Hi, What is the first argument of the String array in main() method? Thanks... array in very efficient manner. For details on What is the first argument
when will we get JasperException and parseException?
when will we get JasperException and parseException?  when will we get JasperException and parseException
how can create pop() method in this program ,Or how can delete image in it when i press pop button in runtime ??? please help me ...
* to the selected value and returns the label, set up * to display the text...how can create pop() method in this program ,Or how can delete image in it when i press pop button in runtime ??? please help me ...   
HOW TO DISPLAY 2 SET OF CONTROLS
HOW TO DISPLAY 2 SET OF CONTROLS  i can be display one row by selecting value from drop down box BUT ALSO i need to display 2 rows by selecting value from drop down box of textbox's and radio button,drop down box using this code
how to display default radio button in struts2.0 for first time login - Struts
how to display default radio button in struts2.0 for first time login  hi, this is suresh jampala, i have one question regarding struts2.0,how can i display default radio button in struts2.0 when ever i loggedin first time
display current time when using datetimepiker in struts2
display current time when using datetimepiker in struts2  how to display current time when using datetimepiker in struts2 I set displayFormat="dd/MM/yyyy HH:mm:ss" but it doesn't work. Display value is always : 19/11/2010 00:00
Array in Java
of same type in memory. The size or length of an array is fixed when the array is created. Each item in an array is called an element. First element... are "an array of arrays". We can have an array of ints, an array of Strings
Names
Names  Sir why we use st.charAt(0). Is there no subsitute for this. Because i m biginner. Thnx
Names
: JOptionPane.showMessageDialog(null,"Invalid"); } } }   Display name which starts
C calculate sum of first and last element of array
enters the number. Then using the index of the array, we have found first...C calculate sum of first and last element of array In this section, you will learn how to calculate sum of first and last element from the array of five
To find first two maximum numbers in an array,using single loop without sorting array.
To find first two maximum numbers in an array,using single loop without sorting array.  Java program to find first two maximum numbers in an array,using single loop without sorting array
To find first two maximum numbers in an array,using single loop without sorting array.
To find first two maximum numbers in an array,using single loop without sorting array.  Java program to find first two maximum numbers in an array,using single loop without sorting array
display the generated image from byte array - Struts
display the generated image from byte array  how to create image from byte array using struts and display it in struts html.please give me the sample code
display the hidden text from that row, when onclick on a row of 1- 10
display the hidden text from that row, when onclick on a row of 1- 10  Using JSP: I'm displaying a set of values from the databse in a table rows (1 to 10)in jsp page, when onclick on one of the view row, it has to submit