I want to go through each character in a String and pass each character of the String as a String to another function.
String s = "abcdefg";
for(int i = 0; i < s.length(); i++){
newFunction(s.substring(i, i+1));}
or
String s = "abcdefg";
for(int i = 0; i < s.length(); i++){
newFunction(Character.toString(s.charAt(i)));}
The final result needs to be a String.
So any idea which will be faster or more efficient?
As usual: it doesn’t matter but if you insist on spending time on micro-optimization or if you really like to optimize for your very special use case, try this: