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

 
 


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

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 Pages:
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
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
Identifier Names
- Start with uppercase Class and interface names start with an uppercase letter.... For example, BorderLayout.NORTH. When constant names are made from multiple words... Java NotesIdentifier Names Getting the names of things right is extremely
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 ...   
Handling Key Press Event in Java
the handling key press event in java. Key Press is the event is generated when you.... When you press or release keys for the writing purpose then key events... to the panel. Then the panel and the label have been set to the frame in the program. When
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
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
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
Variable Names
with good names. Why would I choose bad names in the first place? When... first letter. Internal words start with capital letters. Variable names should.... It's worth spending some time to get good names. When I come back to a program of mine
Using Unicode Variable Names - Java Tutorials
it. Until next week, when we celebrate our first anniversary as the most...". This week, we will look at the strange things that happen when we try to use unicode...! South Africa has just become the cheapest country in the world! We are the first
Array
only showroom (capacity: 10 seats). Your application should display... numbered from 6 to 10. Your application should then display a softcopy of the ticket.... It should also display the total number of Twin Seats and Normal Seats
Java: Names
Ruby). Camel case marks the start of a new word by writing the first letter... Java: Names Names should be meaningful and follow conventions Source code..., the names should be meaningful and they should follow the Java conventions
Class names don't identify a class - Java Tutorials
Class names don't identify a class In JDK 1.2 the Sum Microsystems have added... but also by its context for which it was loaded. For this you need to set... public class FirstClass{ public String toString(){ return "This is a First
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
Sorting Country names alphabetically
Sorting Country names alphabetically  Hello, I have a list of country names in an array. I need a jsp code which will sort me the country names in an alphaberical order. It would be more useful when I get the coding using
array example - Java Beginners
, with String properties for first and last names, and property called... get and set methods for an array property - it exposes too much of the inner... of the array or of the array's contents). Instead, we can control the array
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
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
OOP Tutorial [first draft]
Let's say that we want to represent a time of day necessary for recording when... variables. The Java convention is to begin such method names with "get" or "set... Java: OOP Tutorial [first draft] Table of contents Introduction
Writing your First WAP Application.
screens. Cellular device displays first card when... are using to display the paragraph. We can use <p>...; Writing your First
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
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
SQL All Column Names
SQL All Column Names       SQL All Column Names is useful when you want to see the Field, Type, Null... on 'SQL All Column Names'. To understand and grasp the example we create a table
To display suggestions in a text box - Ajax
:'A'), the names that starts from 'A' have to display in the text box. The names must be get from database,Please help me to do this task. Example: When i... to display( These values should get from exisiting database). Name: A( When i
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
Set Interface
the sorted list of the set. The first( ) and the last( ) methods display the first & last elements of the set respectively. Download this Program...] The First element of the set is: 10 The last element of the set is: 60
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      
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
First Ajax Example
Ajax First Example - Print Date and Time       In this section we will create a simple... the time data is retrieved from the server, it uses javascript and css to display
Java Array Declaration
It is essential to assign memory to an array when we declare it. Memory is assigned...; As we declare a variable in Java, An Array variable is declared... type and the array's name. By type we mean the type of elements contained
Array Delete
you to understand Array Delete Example. For this we are using JavaScript... display ( ).This function include an array variable that is used to instantiate... to modify an array, removing any sequence from preexisting set of element
Prepared Statement Set Object
are not known when the Sql statement is created. So we use "?"... PreparedStatementSetObject Prepared Statement Set Array Example! 1 Record... Prepared Statement Set Object    
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
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
Set Timestamp by using the Prepared Statement
interface. Working with program, first of we will establish the connection with MySQL... Set Timestamp by using the Prepared Statement       In this JDBC tutorial we
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
SET Syntax
. In this section we are describing you the use of SET statement to assign the values for system... variable.  We can get the list of system variable names and values by the SHOW.... But if it is set to 0 then we have to use COMMIT to for accepting the transaction
GUI Tutorial I - FIRST DRAFT
to monitor user interaction with the interface. When we are finished setting... should compile TinyWindowGUI3 first. Execution. When you run this program, you... variable. The content pane of this JFrame is now set to the JPanel that we created
enable users to enter names - Java Beginners
; private String letter = ""; private boolean win = false; public... a) { count++; if(count % 2 == 0){ letter = "O"; } else { letter = "X...(); pressedButton.setText(letter); pressedButton.setEnabled(false); for(int i=0; i<=7
Welcome! to the News letter archive
News Letter Archive       In this page we are listing down the email news letter sent our users.   Newsletters are regularly distributed
Using image in WML We can use the
this lesson we will write application that images. We can use the <img> tag to display the image in our document..., in that case we can use the alt property of <img>
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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.