);\n printTestForValidIdentifierCharacter('#');\n printTestForValidIdentifierCharacter('n');\n printTestForValidIdentifierCharacter('t');\n }\nThe output from the above appears below.TEST FOR FIRST AND OTHER CHARACTERS IN A VALID JAVA NAME\nCharacter 'A': VALID FIRST character and VALID OTHER character in a Java name.\n Type of 'A': 1\nCharacter 'a': VALID FIRST character and VALID OTHER character in a Java name.\n Type of 'a': 2\nCharacter '1': NOT VALID FIRST character and VALID OTHER character in a Java name.\n Type of '1': 9\nCharacter '': NOT VALID FIRST character and NOT VALID OTHER character in a Java name.\n Type of '': 24\nCharacter '_': VALID FIRST character and VALID OTHER character in a Java name.\n Type of '_': 23\nCharacter ': VALID FIRST character and VALID OTHER character in a Java name.\n Type of ': 26\nCharacter '#': NOT VALID FIRST character and NOT VALID OTHER character in a Java name.\n Type of '#': 24\nCharacter '\n': NOT VALID FIRST character and NOT VALID OTHER character in a Java name.\n Type of '\n': 15\nCharacter ' ': NOT VALID FIRST character and NOT VALID OTHER character in a Java name.\n Type of ' ': 15\nBecause the Character.getType(char) method has been with us for quite a while and predates the J2SE 5-introduced enum construct, this method returns primitives integers. One can refer to Java's Constant Field Values to determine what each of these constants stand for.To make the above example's output a little more readable, I have added a simple \"converter\" method that converts the returned int to a more readable String. I have only added switch cases for the integers returned from my example, but one could add cases for all supported types represented by different integers. public static String extractReadableStringFromJavaCharacterTypeInt(\n final int characterTypeInt)\n {\n String characterType;\n switch (characterTypeInt)\n {\n case Character.CONNECTOR_PUNCTUATION :\n characterType = \"Connector Punctuation\";\n break;\n case Character.CONTROL :\n characterType = \"Control\";\n break;\n case Character.CURRENCY_SYMBOL :\n characterType = \"Currency Symbol\";\n break;\n case Character.DECIMAL_DIGIT_NUMBER :\n characterType = \"Decimal Digit Number\";\n break;\n case Character.LETTER_NUMBER :\n characterType = \"Letter\/Number\";\n break;\n case Character.LOWERCASE_LETTER :\n characterType = \"Lowercase Letter\";\n break;\n case Character.OTHER_PUNCTUATION :\n characterType = \"Other Punctuation\";\n break;\n case Character.UPPERCASE_LETTER :\n characterType = \"Uppercase Letter\";\n break;\n default : characterType = \"Unknown Character Type Integer: \" + characterTypeInt; \n }\n return characterType;\n }\nWhen the integers returned from Character.getType(char) in the example two listings ago are run through this switch statement, the revised output appears as shown next.TEST FOR FIRST AND OTHER CHARACTERS IN A VALID JAVA NAME\nCharacter 'A': VALID FIRST character and VALID OTHER character in a Java name.\n Type of 'A': Uppercase Letter\nCharacter 'a': VALID FIRST character and VALID OTHER character in a Java name.\n Type of 'a': Lowercase Letter\nCharacter '1': NOT VALID FIRST character and VALID OTHER character in a Java name.\n Type of '1': Decimal Digit Number\nCharacter '': NOT VALID FIRST character and NOT VALID OTHER character in a Java name.\n Type of '': Other Punctuation\nCharacter '_': VALID FIRST character and VALID OTHER character in a Java name.\n Type of '_': Connector Punctuation\nCharacter ': VALID FIRST character and VALID OTHER character in a Java name.\n Type of ': Currency Symbol\nCharacter '#': NOT VALID FIRST character and NOT VALID OTHER character in a Java name.\n Type of '#': Other Punctuation\nCharacter '\n': NOT VALID FIRST character and NOT VALID OTHER character in a Java name.\n Type of '\n': Control\nCharacter ' ': NOT VALID FIRST character and NOT VALID OTHER character in a Java name.\n Type of ' ': Control\nThe SourceVersion class is useful for dynamically determining information about the Java source code version and the keywords and valid names applicable for that version. The Character class also provides useful information on what a particular character's type is and whether or not that character can be used as the first character of a name or as any other character in a valid name.","wordCount":1999,"datePublished":"2009-10-25T00:24:00-04:00","dateModified":"2009-10-25T00:24:00-04:00","keywords":"Software Development","mainEntityOfPage":"https:\/\/www.infoworld.com\/article\/2157881\/java-sourceversion-and-character-2.html"}]