Saturday, April 3, 2010

Collections

Hi all
JDK is now fixed with a rich collection frame work which, replaces all those classes which java developers used handle group of objects.
Have a taste of it : We can go for collections to get rid off and avoid unnecessary checkings on size for eg:- If you are intending to use a HashMap :
I'm taking the example of an airline comapany
Map sectors = new HashMap();
sectors.put(resultSet.getString("sectorCode"), resultSet.getString(sectorName));
and can retrieve any "sectorName" :then sector.get("COK") will give the sectorName of "COK"

you iterate the same using
Iterator sectorNameItr = sectors.keySet().iterator();

No comments: