0Pricing
Java Academy · Lesson

StringBuilder Methods

append, insert, reverse, delete.

More Than append

Beyond append, StringBuilder offers many methods to modify text in place: insert, delete, reverse, replace, and more. Let us explore the most useful ones.

insert

insert(index, value) places content at a specific position, shifting the rest to the right.

public class Main {
    public static void main(String[] args) {
        StringBuilder sb = new StringBuilder("Hello World");
        sb.insert(5, ",");
        System.out.println(sb);
    }
}

All lessons in this course

  1. Why Strings Are Immutable
  2. Building Strings with StringBuilder
  3. StringBuilder Methods
  4. StringBuilder vs StringBuffer
← Back to Java Academy