Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



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

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


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


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


Advertisement
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
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
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
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 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: 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
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
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
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
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
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
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 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 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
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
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 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
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
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
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
JNDI names in netbeans
JNDI names in netbeans  how to create a JNDI names in netbeans
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
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
 

 

 

DMCA.com