I am getting a strange return for the below block of code (sets of integer values):
public String doubleChar(String str) {
String answer = "";
for (int i = 0; i < str.length(); i++) {
answer = answer + (str.charAt(i) + str.charAt(i));
}
return answer;
}
Opposed to the correct output value (a duplication of the strings chars) when I remove the parentheses enclosing the str.chatAt method calls in the first statement line of the loop:
answer = answer + str.charAt(i) + str.charAt(i);
Any help is appreciated, could not track down online.
Thanks