Tarun Oohri wrote:Hi Everyone
1. If String are immutable then how come we are able to append into the String using + operator ?
Thanks!!!
We are not appending to the existing String. We are creating a new String whose value is a result of the concatenation of those two Strings. So the current String is not changed but a new String is created. That's why you don't just have
but
to make sure that the old reference is now pointing to the new String.
Tarun Oohri wrote:Hi Everyone
2. Why we can not cast (String)char ?
Because String does not extend char or Character.