Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static String[] splitByCamelCase(String name) {
        List<String> parts = new ArrayList<String>();
        StringBuilder b = new StringBuilder();
        for (int i = 0; i < name.length(); i++) {
            if (i > 0 && Character.isUpperCase(name.charAt(i))) {
                parts.add(b.toString());
                b = new StringBuilder();
            }
            b.append(Character.toLowerCase(name.charAt(i)));
        }
        parts.add(b.toString());
        return parts.toArray(new String[] {});
    }
}