[!INDEX]
- String Buffer
- Code Example+ use append hello + world
- Syntax (ASC)
- StringBuilder
- Code Example+ use append hello + world
- constructor+method
1. String Buffer
[!NOTE]
- (Mutable, synchronized, thread safe, multi-threaded context, multiple modifications to a string )
2. Code Example+ use append hello + world
StringBuffer sb = new StringBuffer("Hello");
sb.append(" World"); // Modifies the existing object
System.out.println(sb.toString()); // Output: Hello World
3. Syntax (ASC)
public final class StringBuffer extends AbstractStringBuilder
implements java.io.Serializable, CharSequence {
}
4. StringBuilder
[!NOTE]
- (Mutable, not synchronized, no thread safe, single-threaded environments, modified frequently.)
5. Code Example+ use append hello + world
StringBuilder sb = new StringBuilder("Hello");
sb.append(" World"); // Modifies the existing object
System.out.println(sb.toString()); // Output: Hello World
6. constructor+method