Computer Applications
What are String and StringBuffer classes of Java?
Java String Handling
12 Likes
Answer
In Java, we can work with characters by using String and StringBuffer class.
String class — The instances of String class can hold unchanging string, which once initialized cannot be modified. For example,
String s1 = new String("Hello");
StringBuffer class — The instances of StringBuffer class can hold mutable strings, that can be changed or modified. For example,
StringBuffer sb1 = new StringBuffer("Hello");
Answered By
9 Likes
Related Questions
Which of these constructors is used to create an empty String object?
- String( )
- String(void)
- String(0)
- None of the mentioned
Which of these is an incorrect statement?
- String objects are immutable, they cannot be changed.
- When you assign a new value to a String object, Java internally creates another String object.
- StringBuffer is a mutable class that can store sequence of characters.
- String objects are actually arrays of characters.
How are Strings different from StringBuffers ?
How can you convert a numeric value enclosed in a string format ?