What is wrong with the code. It works ok but the web doesn't accept the last condition.
Any suggestions?
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();
String[] stringArray = s.split(" ");
for (int i = 0; i < stringArray.length; i++) {
if (i < stringArray.length - 1) {
String name = stringArray[i];
String newName = name.substring(0, 1).toUpperCase() + name.toLowerCase().substring(1);
System.out.print(newName);
System.out.print(" ");
} else{
String name = stringArray[i];
String newName = name.substring(0, 1).toUpperCase() + name.toLowerCase().substring(1);
System.out.print(newName);
}
}
}
}