Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • "String literals are the same". Commented Nov 19, 2015 at 10:26
  • The compiler is just smart enough to notice that s2 just consists of two literals, and will combine them to the literal my computer. Since this literal exists yet, s1 and s2 are pointing to the same reference of my computer. Commented Nov 19, 2015 at 10:30
  • Constants in Java should be moved to the static content. Commented Nov 19, 2015 at 10:31
  • Really sorry! I have edited the question now. Commented Nov 19, 2015 at 10:33
  • 1
    @swdeveloper biziclop answer actually explains the behavior pretty good. Commented Nov 19, 2015 at 10:36