Results 1 to 4 of 4
Thread: what is <....>
- 07-05-2008, 11:04 PM #1
Member
- Join Date
- Jul 2008
- Posts
- 5
- Rep Power
- 0
what is <....>
Hi All,
am newbie to java , i have read some code examples and i have found some declaration like this
Hashtable<String, String> properties = new Hashtable<String, String>();
or something like
private static HashMap<String,JMSSenderTest> jmsSenders = new HashMap<String,JMSSenderTest>();
i am not able to understand what is meaning of that especially about the <String,String>
so what does the symbol <....> indicates
sorry for the silly question
- 07-05-2008, 11:17 PM #2
That syntax is part of the Generic coding for java. Go to the Sun's tutorial and read up.
Generics is a way of telling the compiler how you are going to use a class and have the compiler check that you use it correctly.
Many of the classes that use the Generic coding technique allow the use of Objects and are prone to problems with type casting and wrong types being used. Generics allows the compiler to check on the coder's use of a class.
- 07-05-2008, 11:19 PM #3
Member
- Join Date
- Jul 2008
- Posts
- 28
- Rep Power
- 0
Those brackets signify parametrized type definitions. If you want an ArrayList of Strings then you would define it as such:
The code example you have is a map of key-value pairs where the keys are Strings and the values are JMSSenderTest.Java Code:ArrayList<String> list = new ArrayList<String>();
- 07-06-2008, 01:32 AM #4
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks