Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

public class Main {
    private static final String VOID_STRING = "";
    private static final String SPACE = " ";

    private static String addSpaceIfRequired(String value, int index) {
        if (index == 0)
            return VOID_STRING;
        char precedingChar = value.charAt(index - 1);
        char thisChar = value.charAt(index);
        if (Character.isLowerCase(precedingChar) && Character.isUpperCase(thisChar)
                || Character.isLetter(precedingChar) && Character.isDigit(thisChar)
                || Character.isDigit(precedingChar) && Character.isLetter(thisChar)) {
            return SPACE;
        }
        if (index + 1 == value.length())
            return VOID_STRING;
        char nextChar = value.charAt(index + 1);
        if (Character.isUpperCase(precedingChar) && Character.isUpperCase(thisChar)
                && Character.isLowerCase(nextChar)) {
            return SPACE;
        }
        return VOID_STRING;
    }
}