Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

public class Main {
    public static void main(String[] args) {
        // Length is 5
        StringBuilder sb = new StringBuilder("Hello");

        // Now the length is 7 with last two characters as null character '\u0000'
        sb.setLength(7);

        // Now the length is 2 and the content is "He"
        sb.setLength(2);

    }
}