String string = "ha"; StringBuilder repeated = new StringBuilder(); int count = 5; while (count-- > 0) repeated.append(string);