There is a code which capitalize first word letter. However I wasn't able to find a method to convert char array back to String:
For example: "hello world" code transforms it to ["H", "e", "l", "l", "o", " ", "W", "o", "r", "l", "d"]
I want to transform it back to "Hello World"
public class Solution
{
public static void main(String[] args) throws IOException
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String s = reader.readLine();
char[] chars = s.toCharArray();
chars[0] = Character.toUpperCase(chars[0]);
for (int i = 0; i < chars.length; i++){
if (chars[i] == ' '){
chars[i + 1] = Character.toUpperCase(chars[i + 1]);
}
}
System.out.println(chars);
}
}