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

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









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:ADS
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
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 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
Names
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
Java Set iterator with example
Java Set Interface keeps the data without duplicate value. Its one subtype... Set Iterator import java.util.*; public class setiterator { public static void main(String[] args) { Set s = new TreeSet(); s.add(1000); s.add
Java Set Iterator
Set Interface keeps the data without duplicate value. Its one subtype... data. It uses iterator() method to traverse the data Java Set Iterator...(String[] args) { Set s = new HashSet(); s.add("car
SET and SELECT
SET and SELECT  hello, What is difference between SET & SELECT in sql????   hii,ADS_TO_REPLACE_1 SET : The set statement is used to the update query. SELECT : The select statement is used to display the all
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
Chaldean universal identifications names compiler on the application for Funtepoz
Chaldean universal identifications names compiler on the application for Funtepoz  I want to set up criteria on application table. It is chaldean numerology. I want 30 letters and 4 names in the identification and L and E should
pass parameter names and values
pass parameter names and values  What is the <jsp:param> standard action?   The <jsp:param> standard action is used with <jsp:include> or <jsp:forward> to pass parameter names and values
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-dataset'
ModuleNotFoundError: No module named 'names-dataset'  Hi, My... 'names-dataset' How to remove the ModuleNotFoundError: No module named 'names-dataset' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'names-dataset'
ModuleNotFoundError: No module named 'names-dataset'  Hi, My... 'names-dataset' How to remove the ModuleNotFoundError: No module named 'names-dataset' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'names-dataset'
ModuleNotFoundError: No module named 'names-dataset'  Hi, My... 'names-dataset' How to remove the ModuleNotFoundError: No module named 'names-dataset' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'names-dataset'
ModuleNotFoundError: No module named 'names-dataset'  Hi, My... 'names-dataset' How to remove the ModuleNotFoundError: No module named 'names-dataset' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'names-gen'
ModuleNotFoundError: No module named 'names-gen'  Hi, My Python... 'names-gen' How to remove the ModuleNotFoundError: No module named 'names... have to install padas library. You can install names-gen python with following
ModuleNotFoundError: No module named 'names-gen'
ModuleNotFoundError: No module named 'names-gen'  Hi, My Python... 'names-gen' How to remove the ModuleNotFoundError: No module named 'names... have to install padas library. You can install names-gen python with following
ModuleNotFoundError: No module named 'names-dataset'
ModuleNotFoundError: No module named 'names-dataset'  Hi, My... 'names-dataset' How to remove the ModuleNotFoundError: No module named 'names-dataset' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'names-gen'
ModuleNotFoundError: No module named 'names-gen'  Hi, My Python... 'names-gen' How to remove the ModuleNotFoundError: No module named 'names... have to install padas library. You can install names-gen python with following
ModuleNotFoundError: No module named 'names_translator'
ModuleNotFoundError: No module named 'names_translator'  Hi, My... named 'names_translator' How to remove the ModuleNotFoundError: No module named 'names_translator' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'russian-names'
ModuleNotFoundError: No module named 'russian-names'  Hi, My... 'russian-names' How to remove the ModuleNotFoundError: No module named 'russian-names' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'standard-names'
ModuleNotFoundError: No module named 'standard-names'  Hi, My... named 'standard-names' How to remove the ModuleNotFoundError: No module named 'standard-names' error? Thanks   Hi, In your python
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 '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 '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 '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 '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-dataset'
ModuleNotFoundError: No module named 'names-dataset'  Hi, My... 'names-dataset' How to remove the ModuleNotFoundError: No module named 'names-dataset' error? Thanks   Hi, In your python
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_translator'
ModuleNotFoundError: No module named 'names_translator'  Hi, My... named 'names_translator' How to remove the ModuleNotFoundError: No module named 'names_translator' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'russian-names'
ModuleNotFoundError: No module named 'russian-names'  Hi, My... 'russian-names' How to remove the ModuleNotFoundError: No module named 'russian-names' error? Thanks   Hi, In your python
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 '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

Ads