Skip to content

Instantly share code, notes, and snippets.

@aluink
Created February 22, 2012 19:50
Show Gist options
  • Save aluink/1886870 to your computer and use it in GitHub Desktop.
Save aluink/1886870 to your computer and use it in GitHub Desktop.
Java collection evolution
//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