Display set names

Ads

 
 

Share on Google+Share on Google+

Lakshmi
Display set names
1 Answer(s)      5 years and 9 months ago
Posted in : Java Beginners

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

Ads
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
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
JNDI names in netbeans
JNDI names in netbeans  how to create a JNDI names in netbeans
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
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
SET and SELECT
SET and SELECT  hello, What is difference between SET & SELECT in sql????   hii, SET : The set statement is used to the update query. SELECT : The select statement is used to display the all data's in the table
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
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
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
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
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
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
Set interface
Set interface  hello,, What is the Set interface?   hii, The Set interface provides methods for accessing the elements of a finite... is the example of Set Interface in Java. import java.util.*; public class
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 a new feature that allows you to identify a class not only by its name but also by its context for which it was loaded. For this you need to set
Jdbc Get Column Names
Jdbc Get Column Names       The JDBC Get Column Names return you the property of the retrieved... The Tutorial illustrates an example from JDBC Get Column Names The Program
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-scalacheck_2.10 dependency
List of Version of com.slamdata>xml-names-scalacheck_2.10 dependency
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.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.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 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

Ads

 
Advertisement null

Ads