Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * Method to convert case of string into camel case.
     * 
     * @param name
     *            the name
     * @return the string
     */
    private static String toCamelCase(String name) {
        name = name.toLowerCase();
        String[] parts = name.split(" ");
        String camelCaseString = parts[0].substring(0, 1).toLowerCase() + parts[0].substring(1);
        for (int i = 1; i < parts.length; i++) {
            camelCaseString = camelCaseString + toProperCase(parts[i]);
        }
        return camelCaseString;
    }

    /**
     * To proper case.
     * 
     * @param s
     *            the s
     * @return the string
     */
    private static String toProperCase(String s) {
        return s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase();
    }
}