Created
February 22, 2012 19:50
-
-
Save aluink/1886870 to your computer and use it in GitHub Desktop.
Java collection evolution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//How it started | |
Type [] col = getCol(); | |
for(int i = 0;i < col.length;i++){ | |
Type obj = col[i]; | |
//Use obj | |
} | |
//Enter untyped collections | |
//This is worse than before, IMO | |
//since you blindly cast to Type | |
//At least before, arrays were typed. | |
List colList = getCol(); | |
for(Iterator itr = colList.getIterator();itr.hasNext();){ | |
Type obj = (Type)itr.next(); | |
//Use obj | |
} | |
//Enter generic collections | |
//Angelic songs queue up | |
List<Type> col = getCol(); | |
for(Type t : col){ | |
//Use t | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment