Java String with Hebrew word

Introduction

Determines if a string is a Hebrew word.

public class Main {
    public static void main(String[] argv) throws Exception {
        String s = "\u2345";
        System.out.println(isHebrew(s));
    }//  w  w w.  j  a  v a 2  s.c  om

    public static boolean isHebrew(String s) {
        int len = s.length();
        for (int i = 0; i < len; ++i) {
            if (isHebrew(s.codePointAt(i))) {
                return true;
            }
        }
        return false;
    }

    /**
     * Determines if a character is a Hebrew character.
     */
    public static boolean isHebrew(int codePoint) {
        return Character.UnicodeBlock.HEBREW.equals(Character.UnicodeBlock.of(codePoint));
    }
}



PreviousNext

Related