but in 1.5 version we can make the above ArrayList as safe Collection be adding generics
Only String data can be added to the above arrayList
If you try to add any data other than String it will throw an error.
Java training will helps to learn more on Generics.
If you are using Map Generics can be applied for both Key and Value
Example:
HashMap<String,Integer> hm=new HashMap<String,Integer>();
hm.put("hai",new Integer(6));
Note:
If your upgrading your jdk version for old code , newer version will through an warning message to change it, but it wont affect your performance or output of your application.
To know more on Generics online visit
java tutorial
No comments:
Post a Comment