Friday, June 03, 2005

Generics and EFL Save Me Code

I know that Generics and the Enhanced For Loop have been blogged to death but since I just now really started using them here and there I just wanted to publically state my thanks to those Sun guys that improved the language for me.

The old way:
-------------


for(int i=0; i<workstationlist.size(); i++){
list.add(new SelectItem(
((Workstation)workstationList.get(i)).getId(),
((Workstation)workstationList.get(i)).getWorkstation()));
}

The new way:
--------------

for(Workstation w : workstationList) {
list.add(new SelectItem(w.getId(), w.getWorkstation());
}


Gotta love it!

2 comments:

Chuck Reynolds said...

I've Made My First Affiliate Commission!

See How I Did It Here - It's Quick And Easy!

self defense product

Paul Adams said...

Hi, Fellow!I like your blog!
I just came across your blog and wanted to
drop you a note telling you how impressed I was with
the information you have posted here.
I have a wood computer case
site. It pretty much covers wood computer case related subjects.
Come and check it out if you get time :-)
Best regards!