Java tutorial
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); } }