New page: Is there an externally observable difference between following programs? public static String sayHello() { return "Hello World!"; } public static void sayHello() { return "Hello" + " ...
New page
Is there an externally observable difference between following programs?
public static String sayHello() {
return "Hello World!";
}
public static void sayHello() {
return "Hello" + " World!";
}
Of course, there is! Just call the method twice:
<source lang="java">
assert sayHello() == sayHello();
</source>
The first version of the method passes the [[IdentityCheck]] test. The second does not. There are also other differences in [[MemoryAllocations]] as well as [[StringsUsedInConstantPool]].
[[Category:APITypes]]