Home Answers Viewqa Java-Beginners Display set names

 
 


Lakshmi
Display set names
1 Answer(s)      a year and 3 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

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 Pages:
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
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
Names
: JOptionPane.showMessageDialog(null,"Invalid"); } } }   Display name which starts
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
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
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
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
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
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
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
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
Variable Names
Java Notes Variable Names Basic variable naming conventions Choosing good names is probably.... It's worth spending some time to get good names. When I come back to a program of mine
print selected checkbox names in array without form tag
print selected checkbox names in array without form tag  Hi everyone...;% %> [/code] so, i want to display all seleced checked checkbox names, when i click on button but without using FORM tag
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
Set Interface
the sorted list of the set. The first( ) and the last( ) methods display...Set Interface       The Set interface extends the Collection interface
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
JNDI names in netbeans
JNDI names in netbeans  how to create a JNDI names in netbeans
Java: Names
Java: Names Names should be meaningful and follow conventions Source code..., the names should be meaningful and they should follow the Java conventions for capitalization and use of the underscore. Meaningful names Variables, methods
SET Syntax
SET Syntax       The general syntax of SET statement is :   SET variable_assignment [, variable... = expr SET statement is used for assigning the values for different types
Identifier Names
Java NotesIdentifier Names Getting the names of things right is extremely.... Digits: 0-9 Special: _ (underscore) No names can be the same as a Java... worse, no distinction made at word boundaries. Class and interface 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
How to add a columns with a button set to a Jtable built with database result set
How to add a columns with a button set to a Jtable built with database result set  hi, i have to build a gui to display account numbers and account... that button column to the table which is built with database result set. i would thank
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
Set delay time in JOptionPane
Set delay time in JOptionPane       In this section, you will learn how to set the time after which... the user to enter time in seconds and the message to display. After that using
display
display  please tell me how to display the content from database.. if we click on any image using servlets/jsp...please
Spring Set Property
Spring Set Property The Spring Framework has bean support for the Collections. It provide list, set, map and props elements. Here in this tutorial you will see about the set elements which is used to set values inside the set
Spring Set Factory
Spring Set Factory Ths SetFactoryBean is a simple factory for shared Set instance. The set element is defined in the xml bean definitions. The setSourceSet method set the source Set which is written in xml list element
Having problem to set font and color
Having problem to set font and color  Hello Sir, i have some problem to set font and color in my program.Can you take a look for the moment please...(); //Display the result JOptionPane.showMessageDialog(null,"Thank
Display Image in Java
Display Image in Java     ...): Use this method to set the size of the frame. setVisible(boolean b): Pass the boolean value as true to display the image or Vice-Versa. Here we
To display suggestions in a text box - Ajax
:'A'), the names that starts from 'A' have to display in the text box. The names must be get from database,Please help me to do this task. Example: When i...To display suggestions in a text box  Hi All, I have a requirement
Getting Columns Names using Servlets
Getting Columns Names using Servlets   ... helps us to write on the browser. To get a column names from the database... the PreparedStatement object. To get the column names from the database we firstly need
Set the size of visual component in Flex4
Set the size of visual component in Flex4: Flex 4 provide mechanism to set Size of the visual components. There are two different ways to set Size... 2.Explicit sizing:- If user want to set Size in pixel then set Width and Height
Pick random element from Set
Pick random element from Set A Set is a collection that contains no duplicate... the mathematical set abstraction. Here, we are going to pick an element randomly from the elements of Set. For this, we have added five integer elements
Wiring References To Set Element
to demonstrate how set element is used. Product.java: The product class contains property... to provide unique values to the Set or List type property of the Product class. Here...()); } } } If we provide two same objects to the set property then it considers only one
Hibernate Criteria Set Max Results
Hibernate Criteria Set Max Results The set max result of hibernate criteria... of set max result is given below CriteriaSetMaxResult.java package... it will display message as shown below: Hibernate: select this_.roll
Display helloworld using servlet in jboss
Display helloworld using servlet in jboss  import java.io.*; import... in WEB-INF folder.later i wrote a deploy.cmd @echo off set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_33 set JBossHome=C:\Program Files\software
How to Display Data in a tree structure on the GUI
How to Display Data in a tree structure on the GUI  how to display data in a tree structure on the GUI? I need this sort of UI to display data showing a set of rules showing various conditions and the actions related
Using Unicode Variable Names - Java Tutorials
Using Unicode Variable Names 2001-11-23 The Java Specialists' Newsletter [Issue 036] - Using Unicode Variable Names Author: Dr. Heinz M. Kabutz... Names A few months ago, I was reading a book written by the authors of Java
Simple Procedure to display Hello World
Simple Procedure to display Hello World       Procedure is a set of SQL statement enclosed... that helps you to display 'Hello World'. In this Example, we create a procedure
display from select box - JSP-Servlet
display from select box  I am doing a jsp project. In this jsp project i have to show the photos in one cell depending on the selection from other... in a seperate folder and the photo's file names are stored in database.How can it be done
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
Programming: Initials 1
________________________________________ Write a program that asks for names and displays the initials. Ask the user... the first characters from both the first and last names. Use the toUpperCase() method to convert them to upper case. Display the initials to the user
How to set a variable value using velocity
How to set a variable value using velocity       This Example shows you how to set variable value.... #set($list[Ajay, Bhanu, Komal, Shuki, Rakesh
Set Timestamp by using the Prepared Statement
Set Timestamp by using the Prepared Statement... will teach how to set the Timestamp in database table by using... then it will display a message "row(s) affected" otherwise it shows "

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.