CamelCase Converter

Use Camel Case in Java

There is no native function in Java to convert strings to Camel Case. But you can use our large Case Converter Library to convert single strings or texts in your Java programs into camel case notation. You can get it on GitHub:

JAVA Case Converter
https://github.com/toolpage/java-case-converter

Example call in Java:

CaseConverter.convertToCamelCase(Camel case notation"); // CamelCaseNotation

Camel Case method for Java

If you don't want to use our library and only need a small function, this method might help you. Just integrate it into an existing or new class:

public static String convertToCamelCase(String value) { StringBuilder returnValue = new StringBuilder(); String throwAwayChars = "()[]{}=?!.:,-_+\\\"#~/"; value = value.replaceAll("[" + Pattern.quote(throwAwayChars) + "]", " "); value = value.toLowerCase(); boolean makeNextUppercase = true; for (char c : value.toCharArray()) { if (Character.isSpaceChar(c) || Character.isWhitespace(c)) { makeNextUppercase = true; } else if (makeNextUppercase) { c = Character.toTitleCase(c); makeNextUppercase = false; } returnValue.append(c); } return returnValue.toString().replaceAll("\\s+", ""); }

An exemplary use of this method:

convertToCamelCase("Camel case notation"); // CamelCaseNotation

Other Implementations