See below code,
public void processSomething(Collection<AnObject> c) {
for (AnObject object : c) {
object.processSomething();
}
}The compiled bytecode of the above code is the same as it is in 1.4 - 5.0 merely converts the code for you.
Actually generics is not only the new J2SE JDK5.0 feature exists in above example, you will also notice the enhanced for loop. But I'm only going to talk about generics. Sometimes you will notice people putting different types of object into a same collection which severely reduce the code maintainability and readability. Besides that,
ClassCastException drives you crazy. Anyway, we can now get rid of those issues after introducing of Generics. Guys, it is a good time to start embracing Tiger! Enjoy coding!