I solved this task this way:
char[] list = s.toCharArray();

        for (int i = 0; i < list.length; i++) {
            list[0] = Character.toUpperCase(list[0]);
            String n = String.valueOf(list[i]);

            if (n.equals(" "))
                list[i+1] = Character.toUpperCase(list[i+1]);

        }
but I think it's not exactly the right solution, because if I input space at the end in the IDE it will generate an exception.