java get a string out of a for loop code example
Example 1: java loop through string
String s = "...stuff...";
for (int i = 0; i < s.length(); i++){
char c = s.charAt(i);
}
Example 2: loop and save letters in a string java
StringBuilder phone = new StringBuilder();
for (int i = 0; i < number.length(); i++){
if (Character.isLetter(number.charAt(i))){
phone.append(getNumber(Character.toUpperCase(number.charAt(i))));
}else{
phone.append(number.charAt(i));
}
}
System.out.println("Your number is " + phone.toString());