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); } } }
4 Answers
+ 1
If you want to replace first character of every word try this:
https://code.sololearn.com/cyQB56iRtg01/?ref=app
0
is there another way to change the first letter of every word in a line?
0
Yes you can use StringBuilder class or use
splitChar[index].substring(0, 0) + 'q' + splitChar[index]. substring (1)
0
Blue!! Can you show me how the full code should look like?