0

whats the problem?

import java.util.*; public class Main { public static void main(String[] args) { String myLine = "hello, my name is Yahel!"; String[] splitLine = myLine.split(" "); //separating the words from each other (spliting)... char[] splitChar = splitLine[0].toCharArray(); //separating the Characters from each word. splitChar[].replace (splitChar[] , "q"); //replacing the first letter of the first word to "q". //printing the result: for (char a : splitChar){ System.out.println(a); } } }

23rd Jun 2020, 12:22 PM
Yahel
Yahel - avatar
4 Respuestas
+ 1
If you want to replace first character of every word try this: https://code.sololearn.com/cyQB56iRtg01/?ref=app
23rd Jun 2020, 1:02 PM
Blue!!
Blue!! - avatar
0
is there another way to change the first letter of every word in a line?
23rd Jun 2020, 1:34 PM
Yahel
Yahel - avatar
0
Yes you can use StringBuilder class or use splitChar[index].substring(0, 0) + 'q' + splitChar[index]. substring (1)
23rd Jun 2020, 2:55 PM
Blue!!
Blue!! - avatar
0
Blue!! Can you show me how the full code should look like?
23rd Jun 2020, 7:22 PM
Yahel
Yahel - avatar