This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
[Sajid]: i mean b.toString() should come as a string literal...!!
According to what? There was a literal involved in the construction of the Byte, but nothing says that toString() must return the same object. In fact a careful reading of the API tells is this is not allowed - toString) is required to return a new String object here. (That was probably unnecessary and even wrong for Sun to specify in the API, but it's done, and hard for Sun to change after it's been released.) [ May 17, 2005: Message edited by: Jim Yingst ]
Is it because m and n get their values at runtime String objects m and n are not placed in String Literal Pool. When intern() method is called on them they are checked against the pool if the value is not available then they are added to it and checked against them again and returns true.