You need to look what System.out.println(sb); actually does. It calls in class java.io.PrintStream this method. (because a StringBuilder extends Object)
public void println(Object x) { String s = String.valueOf(x); synchronized (this) { print(s); newLine(); } } And, String.valueOf(x) calls the toString() method on your StringBuilder.
public static String valueOf(Object obj) { return (obj == null) ? "null" : obj.toString(); } }