get Special Char Length - Java java.lang

Java examples for java.lang:String Unicode

Description

get Special Char Length

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) {
        char c = 'a';
        System.out.println(getSpecialCharLength(c));
    }//from  ww w  . j a v a  2s .c  om

    private static int getSpecialCharLength(char c) {
        if (isLetter(c)) {
            return 1;
        } else {
            return 2;
        }
    }

    private static boolean isLetter(char c) {
        int k = 0x80;
        return c / k == 0 ? true : false;
    }
}

Related Tutorials