Question: string is immutable or mutable in java?
Answer: In Java, all strings are immutable. When you are trying to modify a String , what you are really doing is creating a new one. However, when you use a StringBuilder , you are actually modifying the contents, instead of creating a new one. Java String s are immutable.