Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

how to print a sentence out in a string of camel case java

StringBuilder builder = new StringBuilder();
for (int i = 0; i < words.length; i++) {
    String word = words[i];
    if (i == 0) {
        word = word.isEmpty() ? word : word.toLowerCase();
    } else {
        word = word.isEmpty() ? word : Character.toUpperCase(word.charAt(0)) + word.substring(1).toLowerCase();      
    }
    builder.append(word);
}
return builder.toString();
Source by www.baeldung.com #
 
PREVIOUS NEXT
Tagged: #print #sentence #string #camel #case #java
ADD COMMENT
Topic
Name
3+3 =