display a list of names(when we press first letter)

display a list of names(when we press first letter)

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 Tutorials/Questions & Answers:
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
Advertisements
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 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
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
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
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
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
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
ModuleNotFoundError: No module named 'mult_list_display'
ModuleNotFoundError: No module named 'mult_list_display'  Hi, My... named 'mult_list_display' How to remove the ModuleNotFoundError: No module named 'mult_list_display' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'mult_list_display'
ModuleNotFoundError: No module named 'mult_list_display'  Hi, My... named 'mult_list_display' How to remove the ModuleNotFoundError: No module named 'mult_list_display' error? Thanks   Hi, In your
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
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
how to display data in List Or grid or in table in Jsp
how to display data in List Or grid or in table in Jsp   <%@page... String P Value in List GIrd or Table please help am able to Print display data In out.print.ln on console But i need to display in List
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
write a java pogram to add elements to linked list using keyboard and display it
write a java pogram to add elements to linked list using keyboard and display it  write a java pogram to add elements to linked list using keyboard and display
how to display action errors in jsp which is in a form list
how to display action errors in jsp which is in a form list  My jsp contains list of forms iterating using display:table, each FORM forms a row. I want to display action errors for individual form in the same row
Version of com.jaredrummler>android-device-names dependency
List of Version of com.jaredrummler>android-device-names dependency
Version of com.real-comp>names-common dependency
List of Version of com.real-comp>names-common dependency
Version of com.slamdata>xml-names-core_2.10 dependency
List of Version of com.slamdata>xml-names-core_2.10 dependency
Version of com.slamdata>xml-names-core_2.11 dependency
List of Version of com.slamdata>xml-names-core_2.11 dependency
Version of com.slamdata>xml-names-core_2.12 dependency
List of Version of com.slamdata>xml-names-core_2.12 dependency
Version of com.slamdata>xml-names-scalacheck_2.10 dependency
List of Version of com.slamdata>xml-names-scalacheck_2.10 dependency
Version of com.slamdata>xml-names-scalacheck_2.11 dependency
List of Version of com.slamdata>xml-names-scalacheck_2.11 dependency
Version of com.slamdata>xml-names-scalacheck_2.12 dependency
List of Version of com.slamdata>xml-names-scalacheck_2.12 dependency
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
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
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
how to display the values of one list in other upon clicking a button in struts2
how to display the values of one list in other upon clicking a button... in struts2.. I have a problem, I have to display the values of one list in other list upon clicking a button...Can any one provide me the sample code.. Hope
How to Display Duplicate elements from more than one List in java?
How to Display Duplicate elements from more than one List in java?  How to Display Duplicate elements from more than one List in java? //I mean common elements from two List? Ex: List a1=new ArrayList(); a1.add(50
display
display  please tell me how to display the content from database.. if we click on any image using servlets/jsp...please
iPhone Baby Name App, iPhone Baby Name, Baby Names application for iPhone
baby. You can add the names to the favorite list and also send... How to download World Baby Names on your iPhone? We...iPhone Baby Name App - World Baby Names
Display related data in other drop down list on selecting one data in one drop down list
Display related data in other drop down list on selecting one data in one drop down list  How to display related datas in dropdown list from database on selecting one data in previous dropdownlist in Java Server Page
How to display content in same page while selecting fron dropdown list
How to display content in same page while selecting fron dropdown list  Thanks for your suggesstion.but Please provide me coding by using only one dropdownlist in javascript or jquery.Thanks in advance
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
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... Example : In this example we are listing the database schema names by using
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
ModuleNotFoundError: No module named 'letter-list'
ModuleNotFoundError: No module named 'letter-list'  Hi, My Python... 'letter-list' How to remove the ModuleNotFoundError: No module named 'letter-list' error? Thanks   Hi, In your python environment
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
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 of tables from the database to the dropdown list... if i select the particular table
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...); } } } } Through the above code, you can display list of files from any
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
JNDI names in netbeans
JNDI names in netbeans  how to create a JNDI names in netbeans
Java list directories
Java list directories In this section, you will learn how to display the list... of both the file and directory names. So in order to get only the directories, we... know java.io.* packages works with both files and directories. So here we have
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
SQL All Column Names
SQL All Column Names       SQL All Column Names is useful when you want to see the Field, Type, Null... The Tutorial briefs you on 'SQL All Column Names'. To understand and grasp the example
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
Maven Dependency names-common >> 1.0.0
You should include the dependency code given in this page to add Maven Dependency of com.real-comp >> names-common version1.0.0 in your project
ModuleNotFoundError: No module named 'names'
ModuleNotFoundError: No module named 'names'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'names' How to remove the ModuleNotFoundError: No module named 'names'

Ads