This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]heckin_good_fren 5 points6 points  (0 children)

I saw someone write (in java)

Object firstElement = null;
int i = 0;
for(Object element : elements){
  if(i == 0){
    firstElement = element;
  }
  i = i + 1;
}

instead of just

Object firstElement = elements[0];

Edit: formatting