I'm so damn proud of myself that I wrote this code......I think it's great! And it works...
But CodeGym doesn't think so...
Please help me and say what's wrong?
Thanks in advance!
package com.codegym.task.task08.task0823;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
/*
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[] words = split(s);
for(String x : words){
System.out.print(upperCase(x) + " ");
}
}
public static String[] split(String sen){
String[] split = sen.split(" ");
return split;
}
public static String upperCase(String word){
ArrayList<Character> list = new ArrayList<>();
char[] symbols = word.toCharArray();
for (char x : symbols) {
list.add(x);
}
Character upper = list.get(0);
list.set(0, Character.toUpperCase(upper));
word = Character.toString(list.get(0));
for(int i = 1; i < list.size(); i++){
Character a = list.get(i);
String help = Character.toString(a);
word += help;
}
return word;
}
}