Created
December 27, 2011 06:16
-
-
Save shohei/1522854 to your computer and use it in GitHub Desktop.
My first public gist
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
import java.util.ArrayList; | |
// "len" scope into the for statement | |
class StopAtHome { | |
public static void main(String[] args) { | |
List<Integer> list = new ArrayList<Integer>(); | |
for (int i = 0; i < 100000; i++) { | |
list.add(i); | |
} | |
// print only even number | |
for (int i = 0, len = list.size(); i < len; i++) { | |
if (i % 2 == 0) { | |
System.out.println(list.get(i); | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment