K
Kevin Podsiadlik
I'm relatively new to Java programming, and stumbled across this by
accident. Consider this code fragment:
char[] ch = { 'A', 'B', 'C', '\0' };
String s = new String(ch);
System.out.println(s + "DEF");
Should this print out "ABC" or "ABCDEF"?
When I run it from the command line, the output is "ABCDEF". When I
run it via the Eclipse 3.1.0 SDK, however, the output is "ABC". The
java compiler is the same both times, version j2sdk1.4.2_10 on a Red
Hat Linux system. I can understand how either output might logically
result, but not how different results can come from the same compiler.
How might that be happening?
accident. Consider this code fragment:
char[] ch = { 'A', 'B', 'C', '\0' };
String s = new String(ch);
System.out.println(s + "DEF");
Should this print out "ABC" or "ABCDEF"?
When I run it from the command line, the output is "ABCDEF". When I
run it via the Eclipse 3.1.0 SDK, however, the output is "ABC". The
java compiler is the same both times, version j2sdk1.4.2_10 on a Red
Hat Linux system. I can understand how either output might logically
result, but not how different results can come from the same compiler.
How might that be happening?