Camelcasing String in android

by Wednesday, July 23, 2014 0 comments
CamelCase (camel case, camel caps or medial capitals) is the practice of writing compound words or phrases such that each next word or abbreviation begins with a capital letter. Camel case may start with a capital or, especially in programming languages, with a lowercase letter.



      public static String UppercaseFirstLetters(String str) {  
           boolean prevWasWhiteSp = true;  
           char[] chars = str.toCharArray();  
           for (int i = 0; i < chars.length; i++) {  
                if (Character.isLetter(chars[i])) {  
                     if (prevWasWhiteSp) {  
                          chars[i] = Character.toUpperCase(chars[i]);  
                     }  
                     prevWasWhiteSp = false;  
                } else {  
                     prevWasWhiteSp = Character.isWhitespace(chars[i]);  
                }  
           }  
           return new String(chars);  
      }  

karthik nagarajan

Androider

Welcome to Android-Action Blog. I’m a normal guy, who is passionate about Mobile Coding. Here I am writing about Android. Happy learning

0 comments:

Post a Comment