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 char[] normalizeTrimmedText(char[] ch) {
        char[] ch2 = new char[ch.length];
        boolean inWhitespace = false;
        int j = 0;
        for (int i = 0; i < ch.length; i++) {
            char c = ch[i];
            boolean isWhitespace = Character.isWhitespace(c);
            if (isWhitespace && !inWhitespace) {
                ch2[j] = ' ';
                j++;
                inWhitespace = true;
            } else if (!isWhitespace) {
                ch2[j] = c;
                j++;
                inWhitespace = false;
            }
        }
        char[] ch3 = new char[j];
        for (int i = 0; i < j; i++) {
            ch3[i] = ch2[i];
        }
        return ch3;
    }
}