Delete text from StringBuilder
public class Main {
public static void main(String[] a) {
StringBuilder builder = new StringBuilder("Line 1\n");
builder.append("Line 3\n");
builder.insert(0, "Line 2\n");
System.out.println(builder.toString());
builder = builder.delete(2, 6);
System.out.println(builder.toString());
}
}
Output:
Line 2
Line 1
Line 3
Li
Line 1
Line 3
Home
Java Book
Runnable examples
Java Book
Runnable examples
StringBuilder:
- Check the capacity of StringBuilder object
- Delete text from StringBuilder
- Palindrome with StringBuilder
- Remove substring from StringBuilder