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









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:ADS
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
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
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
when will we get JasperException and parseException?
when will we get JasperException and parseException?  when will we get JasperException and parseException
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
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
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
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 ...
the label, set up * to display the text and image. */ public...()); } return this; } //Set the font and text when no image...how can create pop() method in this program ,Or how can delete image in it when
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
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...: Two-dimensional arrays are "an array of arrays". We can have an array of ints
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
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
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
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
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...;Elements of the first array is :</b><br/>"; print_r($array1
JSP Array
;     Array is defined as the set of similar type of data.... In this given example, we have define Scriptlets that include a String Array consists of five elements. When you want to iterate through this array, you have to use
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
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
Display an textbox when user Clicks checbox in struts Tags - Struts
Display an textbox when user Clicks checbox in struts Tags  Hi Friend. I need an code for to Display text box when the user clicks checkbox in struts.Pls hekp me.. Note:,... using this kind of tags alone.. Thanks
Null value when i set interface object in form controller - Spring
Null value when i set interface object in form controller   Hi all, i am very new about spring and hibernate. i got null value when i set.... when i call this method in form controller ohbillManager.saveBill(ohbill); i
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... of the PHP Array Example, is as follows: Users names are user 1, user 2,user 3
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
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
base the value of first combo box, how i display the second combox - JSP-Servlet
base the value of first combo box, how i display the second combox    i have a combo box for classes. my requirement is when i select the class..., Try the following code: ComboBox var arr = new Array(); arr[11
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
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
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
How to Display an alert message when nothing is selected in jspinner in java?
How to Display an alert message when nothing is selected in jspinner in java?  Hello, i'm trying to code a jspinner in java and i want to display a message when nothing is selected. My initial value is 0 min value = 0 max value
Re: base the value of first combo box, how i display the second combox - JSP-Servlet
Re: base the value of first combo box, how i display the second combox   Dear Sir, in this program when i click on submit button, the corrosponding value of combo box should be sent. but when i clicked to submit button, it do
Re: base the value of first combo box, how i display the second combox - JSP-Servlet
Re: base the value of first combo box, how i display the second combox  ... appear only when i select the class 11th or 12th. please review. your answer: ComboBox var arr = new Array(); arr[11] = new Array("Art","Commerce
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      
How to set the pdfptable as pdf page header when generating the pdf from jsp page. - JSP-Servlet
How to set the pdfptable as pdf page header when generating the pdf from jsp page.  how to set the pdfptable column headers as a header of the documet.i need to display the column headers for every pdf page if pdf documt is 20
Multidimensional Array Java
type. When we have the data of the same type and same scope then its better to store it in an array. We use mostly two types of arrays that is simple array and multi dimensional array.   In the example given below we have
JSP Array Length
;       JSP Array Length is performed when you want.... You can see in the example that we create a Scriptlets that include an array.... array.length( )  : This method is used to display the length of array. Here

Ads