Java String Camel Case Format toCamelCase(String inputString)

Here you can find the source of toCamelCase(String inputString)

Description

to Camel Case

License

Open Source License

Declaration

public static String toCamelCase(String inputString) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String toCamelCase(String inputString) {
        String result = "";
        if (inputString.length() == 0) {
            return result;
        }//from   w  w w  . j  a va 2s.  co  m
        char firstChar = inputString.charAt(0);
        char firstCharToUpperCase = Character.toUpperCase(firstChar);
        result = result + firstCharToUpperCase;
        for (int i = 1; i < inputString.length(); i++) {
            char currentChar = inputString.charAt(i);
            char previousChar = inputString.charAt(i - 1);
            if (previousChar == ' ') {
                char currentCharToUpperCase = Character.toUpperCase(currentChar);
                result = result + currentCharToUpperCase;
            } else {
                char currentCharToLowerCase = Character.toLowerCase(currentChar);
                result = result + currentCharToLowerCase;
            }
        }
        return result;
    }
}

Related

  1. toCamelCase(String input)
  2. toCamelCase(String input)
  3. toCamelCase(String input)
  4. toCamelCase(String input, boolean capitalizeFirsLetter)
  5. toCamelCase(String input, boolean firstCharUppercase, char separator)
  6. toCamelCase(String inputString)
  7. toCamelCase(String name)
  8. toCamelCase(String name)
  9. toCamelCase(String name)