Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static String computePhraseShape(String x) {
        StringBuilder buf = new StringBuilder();
        char lastc = 0;
        for (int i = 0; i < x.length(); i++) {
            char c = x.charAt(i);
            if (Character.isDigit(c))
                c = '0';
            else if (Character.isLetter(c))
                c = Character.isLowerCase(c) ? 'a' : 'A';
            else if (Character.isWhitespace(c) || Character.isSpaceChar(c))
                c = ' ';
            if (c != lastc)
                buf.append(c);
            lastc = c;
        }
        return buf.toString();
    }
}