+ 1
Whats wrong with my code?
import java.util.Scanner; public class Program{ public static void main(String [] args){ Scanner sc = new Scanner(System.in); String str = sc.nextLine(); String [] words = str.split(" "); String[] newWords = new String[words.length]; int i=0; for(String word : words){ char ch = word.charAt(0); newWords[i] = word.replace(ch, '\u0000') + ch + "ay"; i++; } String newSentence = String.join(" ", newWords); System.out.println(newSentence); sc.close(); } }
4 ответов
+ 5
I.K.I.A.T.L ,
see my comments and modifications in the file:
https://code.sololearn.com/cOoozgGm65N3/?ref=app
+ 6
I.K.I.A.T.L ,
i did not step very deep in your code, you can use both codes in an online debugger to see the difference.
+ 1
Lothar
But what's wrong with my code ?!
0
In the line for (String : words) its bad, the correct one would be for(String words; words)