Pls help me to find out why I can't pass the verification, it seems everything is correct. I checked when the string start with a space, or when there are multiple spaces between words. Everything looks exactly like the requirement. Btw, when I use Code Analysis, it shows unknown error, which is pretty strange. Please help me. Thank you.
package com.codegym.task.task08.task0823;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
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();
//write your code here
char[] string = s.toLowerCase().toCharArray();
if (string[0] != 32){
int b = string[0] - 32;
string[0] = (char) b;
for(int i = 1; i < string.length; i++){
if(string[i] == 32 && string[i + 1] != 32) {
int x = string[i + 1] - 32;
string[i + 1] = (char) x;
}
}
} else {
for(int i = 0; i < string.length - 1; i++){
if(string[i] == 32 && string[i + 1] != 32) {
int x = string[i + 1] - 32;
string[i + 1] = (char) x;
}
}
//System.out.print(string[0]);
}
for(int i = 0; i < string.length; i++){
System.out.print(string[i]);
}
}
}