Pages

Wednesday, October 1, 2025

What is a StringBuilder?

 - Mutable sequence of characters.

Unlike, String which is immutable (cannot be changed).

Benefits:

1. Allows you to append, insert or delete characters efficiently without creating a new object each time.

CODE:

public class Main {
    public static void main(String str[]) {
        StringBuilder sb = new StringBuilder();
        sb.append("Hello");
        sb.append(" World");

        System.out.println(sb.toString()); // Output: Hello World
    }
}

No comments:

Post a Comment

how to become red on codeforces by Errichto Algorithms | explained simply in a blog

 Yes. I found an available transcript of the video and summarized it simply. The video is “How To Become Red Coder? (codeforces.com)” by Err...