Skip to content

Instantly share code, notes, and snippets.

@AKB428
Created February 20, 2015 13:19
Show Gist options
  • Select an option

  • Save AKB428/8460ce8ab81815f47074 to your computer and use it in GitHub Desktop.

Select an option

Save AKB428/8460ce8ab81815f47074 to your computer and use it in GitHub Desktop.
Javaのfor最適化は意味あるか否か
public class OptimizeForLoop {
public static void main(String[] args) {
noOptimize(args);
optimize(args);
}
public static void noOptimize(String[] args) {
for (int i = 0; i < args.length; i++) {
System.out.println(args[i]);
}
}
public static void optimize(String[] args) {
for (int i = 0, n = args.length; i < n; i++) {
System.out.println(args[i]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment