|
|
|
|
|
by kbolino
4818 days ago
|
|
You are correct (albeit substituting "class" for "source file" since runtime Java has no concept of source files), although the guarantee is stronger than that. Any two identical literals will refer to the same object, since literals are interned, regardless of what classes "own" them. Chapter and verse: JLS ยง3.10.5, http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#... |
|
> String a = "foo";
vs.
> String a = new String("foo");