public String f2(String string) {
String result = "";
String num = "";
for (int i = 0; i < string.length(); i++) {
if (Character.isDigit(string.charAt(i))) {
int number = Integer.parseInt(string.charAt(i) + "");
if (number > 0 || number < 8) {
number += 1;
num = String.valueOf(number);
}
}
}
return result;
}
Example of input:
123abc
Expected output:
234abc
I solved the increase in the value of the character by 1 unit if it was a number, but I haven't solved the problem of putting the characters together.
Can someone help me?