InterviewSolution
| 1. |
"string Class Is Immutable", Explain The Reason ? |
|
Answer» String class is immutable in Java that means we are UNABLE to CHANGE its value. It is because a String object is always cached in the String pool, and these pools can be shared between various CLIENTS. So there will always a risk that if we change in client's string it will automatically AFFECT all the client's action. So every time when we try to change the String value, it will create a NEW object String class is immutable in Java that means we are unable to change its value. It is because a String object is always cached in the String pool, and these pools can be shared between various clients. So there will always a risk that if we change in client's string it will automatically affect all the client's action. So every time when we try to change the String value, it will create a new object |
|