In: Computer Science
(In java) Return a copy of the string with only its first character capitalized. You may find the Character.toUpperCase(char c) method helpful
NOTE: Each beginning letter of each word should be capitalized. For example, if the user were to input: "United States of America " --> output should be "United States of America" NOT "United states of america"
--------------------------------------
(This code is given)
public class Class1 {
public static String capitalize(String str) {
    //add code here
}
}
/*If you any query do comment in the comment section else like the solution*/
import java.util.Scanner;
public class CapitalizeFirstCharacter {
        public static void main(String[]args) {
                Scanner sc = new Scanner(System.in);
                String input = sc.nextLine();
                String res = "";
                String splitInput[] = input.split(" ");
                for(String s: splitInput) {
                        String firstCharacter=s.substring(0,1);  
                String restCharacter=s.substring(1);  
                res = res + firstCharacter.toUpperCase() + restCharacter + " "; 
                }
                System.out.println(res);
        }
}