I have this homework in my school where I need to separate the numbers and the letters and print them apart. My problem is I can only return one value which is the number not the letters in my if/else statement, I need to return both values so I can print the numbers and the letters separately.
Any suggestion on how I could do it with only one method?
public static String Separation(String output) {
String number = "";
String letter = "";
for (int i = 0; i < output.length(); i++) {
char x = output.charAt(i);
if (Character.isDigit(x)) {
number += x;
} else {
letter += x;
}
}
return number;
}