Please help to write a program which have to display set of names in the array when we click the starting letter (like in gmail if we press the letter it will show the available names)using java
February 11, 2012 at 12:13 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 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... element, it will
display the
set of
countries name from the
array.
Example:ADS
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 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
JavaScript array first element JavaScript
array first element
... a code that makes you easy to
understand in
array first element example... invokes a function
display. This
function include a variable
array that is used
getting an error when set classpathgetting an error
when set classpath Hello Everyone! i have used hssf model for reading excel sheet in my project & i have
set classpath for that jar file but
when i compile the program it will compile correctly but
when i
How to load elements from db when i press next.How to load elements from db
when i
press next. Hello , I am working on a project "Online Book Mart" using JSP and Servlets and I am astuck... means
when i click next, the next 20 books will be displayed from db on the same
When were generics first introduced in Java?When were generics
first introduced in Java? Hi, I want to know
when were generics
first introduced in java?
Generics were introduced to the Java programming language with the release of Java 5.0 in 2014.
Check
HOW TO DISPLAY 2 SET OF CONTROLSHOW 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 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
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
Array in Java of same type in memory.
The size or length of an
array is fixed
when the
array is created. Each item in an
array is called an element.
First element...:
Two-dimensional arrays are "an
array of arrays".
We can have an
array of ints
Java set example the value 10 two times. and
when we compile and
execute the it will
display... to the collection. As
we know
set does not allow
duplicate elements, so after...Java
set example
In this section you will learn about
set interface in java
PHP Array Push ArrayPHP
Array Push
Array
In this tutorial
we will study about pushing one
array... to use
array_push
function. After pushing one
array into another the
first array...;Elements
of the
first array is :</b><br/>";
print_r($array1
JSP Array;
Array is defined as the
set of similar type of data.... In this
given example,
we have define Scriptlets that include a String
Array consists of
five elements.
When you want to iterate through this
array, you have to use
Creating Array in PHP an
Array,
we first needs to write the
Array function. See the
syntax of an
Array...In this video tutorial,
we are going to learn about What is an
Array... of the PHP
Array Example, is as follows:
Users
names are user 1, user 2,user 3
NamesNames Sir why
we use st.charAt(0).
Is there no subsitute for this.
Because i m biginner.
Thnx
Names:
JOptionPane.showMessageDialog(null,"Invalid");
}
}
}
Display name which starts
C calculate sum of first and last element of array enters the number. Then using the index of the
array,
we have found
first...C calculate sum of
first and last element of
array
In this section, you will learn how to calculate sum of
first and last element from the
array of five
Array example of an
array
is decided
when an
array is created. Length in
array cannot... to
understand an
Array example, For this
we are using Java Scripting language...
Array example
Multidimensional Array Java type.
When we have
the data of the same type and same scope then its better to store it in an
array.
We use mostly two types of arrays that is simple
array and multi dimensional
array.
In the example given below
we have
JSP Array Length;
JSP
Array Length is performed
when you want.... You can see in the example that
we create a Scriptlets that include an
array....
array.length( ) : This method is used to
display the length of
array.
Here