String, StringBuffer and StringBuilder in Java | Convert String to StringBuffer or StringBuilder and vice versa
What is String, StringBuilder and StrinfBuffer in java? In this article we talk about String, StringBuffer and StringBuilder in java. String :- String is class in java that represents sequence of characters, it can be word, number, special characters. String represents in Double Quotes (" ") . String is immutable in java. What is immutable? In simple word immutable means can not changable. it con not be replacable. So String is immutable in java. we can not alter String object. So there is one question is pop up in your mind. We can still concatenate or changed String object in java so how it is immutable in Java? Yes, we can concatenate or changed String object but every time we perform these kind of operations it creates new Object of that. See below image you can easily understand. Lets see example of immutability of String. Example 1 :- String demo with immutability public class StringDemo { public static void main(String[] args) { String str = &qu