[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 ]
this prints false...i didn't know toString() also returns a new object... is there any easy way by which i can determine when strings are taken from string pool and when they are created?? sajid
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.