If i gave 1character the name start wth that characteer has to be displayed... using java
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:
Advertisements
Display set namesDisplay 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 arrayDisplay 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
Display first letter of every word in uppercaseDisplay 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
Names:
JOptionPane.showMessageDialog(null,"Invalid");
}
}
}
Display name which starts
NamesNames Sir why
we use st.charAt(0).
Is there no subsitute for this.
Because i m biginner.
Thnx
Select from select list + displaySelect 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
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
Display InformationDisplay 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
JDBC: Listing Table names ExampleJDBC: 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 displaydisplay please tell me how to
display the content from database.. if
we click on any image using servlets/jsp...please
program to display the first ten terms of the seriesprogram to
display the
first ten terms of the series Write a program to
display the
first ten terms of the following series :
1) 1,-3,5,-7,9.....
2) 3,6,12,24.....
3) 2,5,10,17.......
4) 0,1,2,3,6............
5) 0,3,8,15
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...
Example :
In this example
we are listing the database schema
names by using
Sorting Country names alphabeticallySorting 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 current time when using datetimepiker in struts2display current time
when using datetimepiker in struts2 how to
display current time
when using datetimepiker in struts2
I set displayFormat="dd/MM/yyyy HH:mm:ss" but it doesn't work.
Display value is always : 19/11/2010 00:00
Java list filesJava
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...);
}
}
}
}
Through the above code, you can
display list of files from any
Java list directoriesJava
list directories
In this section, you will learn how to
display the
list... of both the file and
directory
names. So in order to get only the directories,
we... 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...
The Tutorial briefs you on 'SQL All Column
Names'. To understand and grasp
the example
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'