string builder

PHOTO EMBED

Mon Jul 08 2024 16:12:35 GMT+0000 (Coordinated Universal Time)

Saved by @signup

public class String_Builder {
    public static void main(String[] args) {
        StringBuilder s = new StringBuilder("hellooooooo");
        System.out.println(s);

        // Deleting characters from index 0 to 2 (exclusive)
        System.out.println(s.delete(0, 3));

        // Deleting the character at index 5
        System.out.println(s.deleteCharAt(5));

        // Inserting "Raghu" at index 3
        System.out.println(s.insert(3, "Varshith"));

        // Printing the length of the StringBuilder
        System.out.println(s.length());

        // Finding the last index of the string "oo"
        System.out.println(s.lastIndexOf("oo"));
    }
}
content_copyCOPY