If i want a String s
which would consist of n
instances of character A
, can this be done cleaner in Java other then
public static String stringOfSize(int size, char ch) {
StringBuilder s = new StringBuilder();
while (size-- > 0) {
s.append(ch);
}
return s.toString();
}
Can we do better? Just wondering.