fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Scanner scan = new Scanner(System.in);
  13. String a;
  14. char b[];
  15. System.out.println("Enter some word ");
  16. if (scan.hasNextLine()) {
  17. a = scan.nextLine().trim();
  18. b = a.toCharArray();
  19. b[0] = Character.toUpperCase(b[0]);
  20. for (int i = 0; i < b.length; i++) {
  21. if (Character.isWhitespace(b[i])) {
  22. b[i + 1] = Character.toUpperCase(b[i + 1]);
  23. }
  24. }
  25. System.out.println(b);
  26. scan.close();
  27. }
  28. }
  29. }
Success #stdin #stdout 0.07s 4575232KB
stdin
dsad dwqdqw d qqw dqwqddqw dq dq wdq dq wdqd q dq wqd qw dq d
stdout
Enter some word 
Dsad Dwqdqw D Qqw Dqwqddqw Dq Dq Wdq Dq Wdqd Q Dq Wqd Qw Dq D