Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Display set of names in array when we press the first letter
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Lakshmi
Display set of names in array when we press the first letter
2 Answer(s)      2 years and 10 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


Advertisement
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]);
            }
        }
    }
}


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
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
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
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
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 ...   
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
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
Java set example
the value 10 two times. and when we compile and execute the it will display... to the collection. As we know set does not allow duplicate elements,  so after...Java set example In this section you will learn about set interface in java
PHP Array Push Array
PHP Array Push Array In this tutorial we will study about pushing one array... to use array_push function. After pushing one array into another the first array...;br/><b>Elements of the first array is :</b><br/>"
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
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
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
Advertisements
 

 

 

DMCA.com