Display set names

Ads
 

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

View Answers

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

Ads









Related Tutorials/Questions & Answers:
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   import java.util.*; class DisplaySetOfNames{ public static void
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
Advertisements
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... the available names)using java   Have a look at the following link
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 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   import javax.swing.*; class Name { public static void main (String
Names
: JOptionPane.showMessageDialog(null,"Invalid"); } } }   Display name which starts
display
display  please tell me how to display the content from database.. if we click on any image using servlets/jsp...please
Java set example
Java set example In this section you will learn about set interface in java. In java set is a collection that cannot contain duplicate element. The set... to add duplicate elements in the set. The set interface has method which
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
Names
JNDI names in netbeans
JNDI names in netbeans  how to create a JNDI names in netbeans
ipad default image names
ipad default image names  i have a problem while launching application in iPad. The Default image that i have set is not displaying in landscape mode correctly. please suggest. Thanks.   ipad Default image names
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'
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 Configurations
Display Configurations   The year is 2136. A lot of things have changed but BITS Pilani still exists. The display technology used now is a WASDLED screen. This display technology consists of a configuration matrix containing
ModuleNotFoundError: No module named 'classification-names'
ModuleNotFoundError: No module named 'classification-names'  Hi...: No module named 'classification-names' How to remove the ModuleNotFoundError: No module named 'classification-names' error? Thanks   Hi
ModuleNotFoundError: No module named 'color-names'
ModuleNotFoundError: No module named 'color-names'  Hi, My Python... 'color-names' How to remove the ModuleNotFoundError: No module named 'color-names' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'distro-names'
ModuleNotFoundError: No module named 'distro-names'  Hi, My Python... 'distro-names' How to remove the ModuleNotFoundError: No module named 'distro-names' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'django-names'
ModuleNotFoundError: No module named 'django-names'  Hi, My Python... 'django-names' How to remove the ModuleNotFoundError: No module named 'django-names' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'flake8-variables-names'
ModuleNotFoundError: No module named 'flake8-variables-names'  Hi...: No module named 'flake8-variables-names' How to remove the ModuleNotFoundError: No module named 'flake8-variables-names' error? Thanks   Hi
ModuleNotFoundError: No module named 'flake8-variables-names'
ModuleNotFoundError: No module named 'flake8-variables-names'  Hi...: No module named 'flake8-variables-names' How to remove the ModuleNotFoundError: No module named 'flake8-variables-names' error? Thanks   Hi
ModuleNotFoundError: No module named 'gen-names'
ModuleNotFoundError: No module named 'gen-names'  Hi, My Python... 'gen-names' How to remove the ModuleNotFoundError: No module named 'gen-names' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'grill-names'
ModuleNotFoundError: No module named 'grill-names'  Hi, My Python... 'grill-names' How to remove the ModuleNotFoundError: No module named 'grill-names' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'human-names'
ModuleNotFoundError: No module named 'human-names'  Hi, My Python... 'human-names' How to remove the ModuleNotFoundError: No module named 'human-names' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'i3-workspace-names'
ModuleNotFoundError: No module named 'i3-workspace-names'  Hi, My... named 'i3-workspace-names' How to remove the ModuleNotFoundError: No module named 'i3-workspace-names' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'names_comparator'
ModuleNotFoundError: No module named 'names_comparator'  Hi, My... named 'names_comparator' How to remove the ModuleNotFoundError: No module named 'names_comparator' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'names_comparator'
ModuleNotFoundError: No module named 'names_comparator'  Hi, My... named 'names_comparator' How to remove the ModuleNotFoundError: No module named 'names_comparator' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'names_comparator'
ModuleNotFoundError: No module named 'names_comparator'  Hi, My... named 'names_comparator' How to remove the ModuleNotFoundError: No module named 'names_comparator' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'names_comparator'
ModuleNotFoundError: No module named 'names_comparator'  Hi, My... named 'names_comparator' How to remove the ModuleNotFoundError: No module named 'names_comparator' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'names_comparator'
ModuleNotFoundError: No module named 'names_comparator'  Hi, My... named 'names_comparator' How to remove the ModuleNotFoundError: No module named 'names_comparator' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'names_comparator'
ModuleNotFoundError: No module named 'names_comparator'  Hi, My... named 'names_comparator' How to remove the ModuleNotFoundError: No module named 'names_comparator' error? Thanks   Hi, In your

Ads