Hi, guys!
I don't know how to fix this code given that " Consider the fact that words might be separated by more than one space.".
Help me, please!
Thank you so much!
package com.codegym.task.task08.task0823;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/*
Going national
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String str = reader.readLine();
//Split sentence into words
String words[]=str.split("\\s");
String newString = " ";
for(String w : words){
String first = w.substring(0,1); //First Letter
String rest = w.substring(1); //Rest of the letters
//Concatenete and reassign after
//converting the first letter to uppercase
newString += first.toUpperCase() + rest + " ";
}
//trim to remove the last redundant blank space
System.out.println(newString.trim());
}
}