I have a simple question regarding optimization. Let's say I have a function that should return a String with one thousand 'A' characters (the number is arbitrary and might be parametrized later). What would be the best way to go around doing so?
StringBuilder sb = new StringBuilder();
for(int i=0; i<1000; i++)
sb.append('A');
return sb.toString();
I've come up with this solution utilizing StringBuilder but I feel there should be a better solution, a memcpy of sorts.
Thanks!