Home Answers Viewqa Java-Beginners display a list of names(when we press first letter)

 
 


Lakshmi
display a list of names(when we press first letter)
3 Answer(s)      a year and 3 months ago
Posted in : Java Beginners

If i gave 1character the name start wth that characteer has to be displayed... using java

View Answers

February 10, 2012 at 10:03 PM


import javax.swing.*;
class Name
{ 
    public static void main (String arg[])
    {

        String st=JOptionPane.showInputDialog(null,"Enter any character");
        char ch=st.charAt(0);
        switch(ch)
        {
            case 'A': JOptionPane.showMessageDialog(null,"Ali\n Azam\n Afzal\n");
            break;
            case 'B': JOptionPane.showMessageDialog(null,"Babar\n Bebo\n Bell\n");
            break;
            default: 
                JOptionPane.showMessageDialog(null,"Invalid");
        } 
     } 
}

February 11, 2012 at 12:12 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]);
            }
        }
    }
}

February 11, 2012 at 12:12 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 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 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 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
Names
: JOptionPane.showMessageDialog(null,"Invalid"); } } }   Display name which starts
Names
Names  Sir why we use st.charAt(0). Is there no subsitute for this. Because i m biginner. Thnx
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 of string consisting of some countries name. We have prompted the user to enter
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
Display list of files from a directory using Java
() method display the list of file names of that directory and if it is having any file then getName() method display their names. We have also showed the size...Display list of files from a directory using Java In this section, you
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
JDBC: Listing Table names Example
JDBC: Listing Table names Example In this section, we are describing how to list all table names of a database using JDBC API. List Tables name in Database... to know the capabilities of DBMS. Some DatabaseMetaData methods gives you list
Java list files
Java list files In this section, you will learn how to display the list of files from a particular directory. Description of code: In the given example, we..., you can display list of files from any directory. Output
Java list directories
Java list directories In this section, you will learn how to display the list... and directory names. So in order to get only the directories, we have created... know java.io.* packages works with both files and directories. So here we have
linked list
, that will prompt a user to enter 10 names and display them in reverse   import...); } Collections.reverse(list); System.out.println("List of names in reverse order:"); for (String names : list) { System.out.println(names
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
Jdbc Get Column Names
, data type. We define a class JdbcGetColumn Names, The main method include a list... Jdbc Get Column Names       The JDBC Get Column Names return you the property of the retrieved
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
Display Information
Display Information  I have a listbox having many names and I have a button "display". I select some names and when I click the button , the names along with the address(they are in database) should be displayed. I am using php
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
List the names of classes used to create button and text box in Java.
List the names of classes used to create button and text box in Java.  List the names of classes used to create button and text box in Java
list and textbox
list and textbox  sir, i want to create a search, where when i... and displayed. Also like a list i should navigate and select the appropriate word which will display the details. similar to a mobile dictionary. how can i do
iPhone Baby Name App, iPhone Baby Name, Baby Names application for iPhone
the names for your baby. You can add the names to the favorite list... the names by letter, origin or sex very quickly. Application will allow... How to download World Baby Names on your iPhone? We
Baby names iPhone, Baby Names Application, Baby name iPhone app, iPhone Baby Names, iPhone baby apps,iPhone baby application
also add and store their favorite names in the list of My Favorite Baby Name... provide a huge list of baby names matching to your origin, sex, religion...Baby names iPhone - Baby Names Applications for iPhone Baby names iPhone
List to be visible only when entering any string into textfield
List to be visible only when entering any string into textfield  how... have to get the name associated with the entered first letter only....if using list i have to get only the selected string the entire other names in the list
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
how to use dropdown list in JSP and display value in same page
how to use dropdown list in JSP and display value in same page  I have a Dropdown list with some values say "A", "B" and "C" When the user selects... in the same page Value selected = C How can we do this in a JSP page
print selected checkbox names in array without form tag
;% %> [/code] so, i want to display all seleced checked checkbox names, when i click on button but without using FORM tag...print selected checkbox names in array without form tag  Hi everyone
JDBC: List of Database "schema" Name
JDBC:  List of Database "schema" Name In this section, we are describing how to list database 'schema' names using JDBC API. List... : In this example we are listing the database schema names by using getCatalogs() method
How to display content in same page while selecting fron dropdown list
How to display content in same page while selecting fron dropdown list ... dropdownlist in jsp page.If i select any value in that list(for eg-rollno),then it want to display all records from table specific to that rollno in that same
display
display  please tell me how to display the content from database.. if we click on any image using servlets/jsp...please
List iterator java example
Java List Iterator is an interface in the collection framework. List is an interface. Its all elements can be traversed by the Iterator. Java List Iterator has methods hasNext() and next() for traversing . Java List Iterator
List Box - JSP-Servlet
). Now when we select the country from the first combobox it will fetch the name... problem is in first list box,value which i selected to get values is not displaying in list box as selected.i need to display that value and values in another list
Select from select list + display
Select from select list + display  i have a select list containing elements, say EmpCode. there are 2 fields below it EmpName and DeptName. As i select EmpCode from the select list, the corresponding EmpName and DeptName should
Use Ordered List In JSP
Use Ordered List In JSP   I created a Sting that contains ... . This string is generated dynamically from the db. When I place the string in the jsp, it does not create the ordered list. I can paste that string in the jsp
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
Generate shuffling in the specified list
void main(String args[]) { // create an array of employee names of string...", "Komal"}; // create list for the specified array of employee. List... and print the list according to the generated random number
List in J2ME
List in J2ME       J2ME Canvas List Example will explain you, how to create list of items. In this example we are going to create a simple list of text, that will show
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... public class FirstClass{ public String toString(){ return "This is a First Class"; } } And another first class in directory2 public class
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
J2ME List Image
with image symbol. In this example we are trying to create list using of List class...;display;   private List list;   private ... J2ME List Image      
Mysql List Tables
'. To understand this example we use show tables query that return the list of tables in database name 'Table_in_girish'. The Syntax used to display the list of tables... Mysql List Tables      
Javascript List Box - JSP-Servlet
Javascript List Box  Thanks vdeepak for sending answer.But i tried ur... Name in above code,when i select semester,it will get data based... itself.my problem is in list box the semester which i selected is not showing
Count number of occurences and print names alphabetically in Java
Count number of occurences and print names alphabetically in Java  I have this code: public class Names { public static void main(String[] args...; } } ArrayList<Integer> list = new ArrayList<Integer>
PHP list class methods
Function get_class_methods gives the all methods names of the given class. It takes input as class name and returns the array of the methods name PHP LIst Class Methods Example <?php class myclass{ function aa
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
Problem to display checkbox item
; I want to display records, when i click on submit button or any dumy button... include next page's selected checkbox in display list on same pages respectively.( i...Problem to display checkbox item  Hi, Following is my code: <
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
list boxs
list boxs  i have two list boxes first list box values from database and i want to assign selected options to the second list box using jsp is it possible to do this in jsp
Mysql List Tables
'. To understand this example we use show tables query that return the list of tables in database name 'Table_in_girish'. The Syntax used to display the list of tables... Mysql List Tables      
Spring List Factory
Spring List Factory Ths ListFactoryBean is a simple factory for shared List instance. The list element is defined in the xml bean definitions. The setSourceList method set the source List which is written in xml list element
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

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.