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 the available names)using java

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 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
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
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
when will we get JasperException and parseException?
when will we get JasperException and parseException?  when will we get JasperException and parseException
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
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
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
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
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 ...   
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
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
JSP Array
;     Array is defined as the set of similar type of data... The Tutorial illustrate an example from 'JSP Array'. To understand the example we... example, we have define Scriptlets that include a String Array consists of five
Creating Array in PHP
an Array, we first needs to write the Array function. See the syntax of an Array...In this video tutorial, we are going to learn about What is an Array and creating an Array in PHP. Basically an Array could be of three different types
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
Display tow dimensional array using one for loop in java
Display tow dimensional array using one for loop in java  Display tow dimensional array using one for loop in java
code to alert when no checkbox is selected and verify them with orther set
code to alert when no checkbox is selected and verify them with orther set ... of checkboxes in the same jsp page , the list names are "attendess" and "Absentees... the list Attendees and also alert me when the user checks same name under both
JavaScript Array
to understand in array first element example. For this we are using Java Scripting... and we will print them.    JavaScript array push() method In this example code of JavaScript array push() method we have
Display tow dimensional array by matrix form using one for loop in java
Display tow dimensional array by matrix form using one for loop in java  Display tow dimensional array by matrix form using one for loop in java
Array example
of an array is decided when an array is created. Length in array cannot... to understand an Array example, For this we are using Java Scripting language... Array example      
display data from database in textbox when id entered in textbox
display data from database in textbox when id entered in textbox  i wanted to enter data in textbox .depending on entered data in textbox data from database should be displayed dynamically in textbox
display table details when selecting table name in drop down liat
display table details when selecting table name in drop down liat  ... database to the dropdownlist in jsp. Example: 1st i want to display the list... be retrived from the database and display in the page... pls its urgent.. help me

Ads