StringBuilder str = new StringBuilder("123456"); // set length equal to 5 str.setLength(5);// str contains "12345"