J
John and Diane Curley
Hi, All:
Just verifying Java Compiler optimization and string literals. If I have
the following method, how many String objects are created in the for loop:
public void method() {
for(int i = 0; i < 1000000; i++) {
System.out.println("xxx");
System.out.println("xxx");
System.out.println("xxx");
System.out.println("xxx");
System.out.println("xxx");
}
}
I say one object is created for the entire for loop and the code is fine, my
colleague says many and this code is inefficient. Any people want to
comment?
Thanks,
John
Just verifying Java Compiler optimization and string literals. If I have
the following method, how many String objects are created in the for loop:
public void method() {
for(int i = 0; i < 1000000; i++) {
System.out.println("xxx");
System.out.println("xxx");
System.out.println("xxx");
System.out.println("xxx");
System.out.println("xxx");
}
}
I say one object is created for the entire for loop and the code is fine, my
colleague says many and this code is inefficient. Any people want to
comment?
Thanks,
John