0
Can't work why?
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner sc=new Scanner(System.in); String letter=sc.nextLine(); String[]num={"0","1","2","3","4","5","6","7","8","9"}; String[]word={"zero","one","two","three","four","five","six","seven","eight","nine"}; for(int i=0;i<=num.length-1;i++){ String letter1=letter.replaceAll(num[i],word[i]);} System.out.println(letter1); } }
2 Antworten
+ 2
'letter1' doesn't exist outside the for-loop.
Also, you should assign to 'letter1' from the already modified string (letter1) , not the source (letter)
String letter1 = letter;
for(int i=0; i<n.length; i++){
letter1 = letter1.replace...
}
0
thank you