Java Data Type How to - Break Strings into chars that are in upper case


We would like to know how to break Strings into chars that are in upper case.


public class Main {
  public static void main(String[] args) {
    String input = "ThisIsATest";
//from  w  w w .  j  av a 2  s.c  o m
    // split into words
    String[] words = input.split("(?=[A-Z])");

    words[0] = capitalizeFirstLetter(words[0]);

    // join
    StringBuilder builder = new StringBuilder();
    for (String s : words) {
      builder.append(s).append(" ");



  private static String capitalizeFirstLetter(String in) {
    return in.substring(0, 1).toUpperCase() + in.substring(1);