Advertisement
Shailrshah

A String in Camel Case

Oct 29th, 2013
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1. class CamelTyping{
  2.     public static void main(String[] args){
  3.         String input = "thank you for visiting my pastebin!";
  4.         String camel = "";
  5.         for(int i = 0; i < input.length(); i++){
  6.             if(i==0 || input.charAt(i-1)==' ') camel+=Character.toUpperCase(input.charAt(i));
  7.             else if(input.charAt(i)==' ') continue; //comment out this line if you want spaces
  8.             else camel+=input.charAt(i);
  9.         }
  10.         System.out.print(camel);
  11.     }
  12. }
  13. //Output:-
  14. //ThankYouForVisitingMyPastebin!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement