Hi there,
The last condition fails. I tried it with several inputs and it runs well but it will not verify.
The mentor recommended: "Consider the fact that words might be separated by more than one space." That is why I trim the string after reading it. However, it will not verify.
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 s = reader.readLine();
s = s.trim();
String [] array = s.split(" ");
for ( String word : array)
{
word = word.substring(0, 1).toUpperCase() + word.substring(1, word.length());
System.out.print(word + " ");
}
}
}