abstract continue for new switch
assert default if package synchronized
boolean do goto private this
break double implements protected throw
byte else import public throws
case enum instanceof return transient
catch extends int short try
char final interface static void
class finally long strictfp volatile
const float native super while
2、其他注意事项
尽管现在已经不再使用关键字const和goto了,但仍旧保留了。这使得当这些C++关键字在程序中使用不当时,Java编译器能够产生更有用的错误消息
尽管true和false看起来应该被当做关键字,但从技术上讲,他们仅仅只是布尔字面常量。与此类似null看起来也应该被当做关键字,但他也仅仅只是空字面常量。
三、关于 Character.isJavaIdentifierPart(int)
/**
* Determines if the character (Unicode code point) may be part of a Java
* identifier as other than the first character.
*
* A character may be part of a Java identifier if any of the following
* are true:
*
*
it is a letter 字母组合(单词)*
it is a currency symbol (such as {@code '$'}) 货币符号如:美元符号*
it is a connecting punctuation character (such as {@code '_'}) 连接标点字符如:下划线*
it is a digit 数字*
it is a numeric letter (such as a Roman numeral character) 数字字母如:罗马数字等*
it is a combining mark 结合字符(举例说明)*
it is a non-spacing mark 非空格标记(举例说明)*
{@link #isIdentifierIgnorable(int)* isIdentifierIgnorable(codePoint)} returns {@code true} for
* the character
*
*
* @param codePoint the character (Unicode code point) to be tested.
* @return {@code true} if the character may be part of a
* Java identifier; {@code false} otherwise.
* @see Character#isIdentifierIgnorable(int)
* @see Character#isJavaIdentifierStart(int)
* @see Character#isLetterOrDigit(int)
* @see Character#isUnicodeIdentifierPart(int)
* @see javax.lang.model.SourceVersion#isIdentifier(CharSequence)
* @since 1.5
*/
public static boolean isJavaIdentifierPart(int codePoint) {
return CharacterData.of(codePoint).isJavaIdentifierPart(codePoint);
}
package java.lang;
abstract class CharacterData {
abstract int getProperties(int ch);
abstract int getType(int ch);
abstract boolean isWhitespace(int ch);
abstract boolean isMirrored(int ch);
abstract boolean isJavaIdentifierStart(int ch);
abstract boolean isJavaIdentifierPart(int ch);
abstract boolean isUnicodeIdentifierStart(int ch);
abstract boolean isUnicodeIdentifierPart(int ch);
abstract boolean isIdentifierIgnorable(int ch);
abstract int toLowerCase(int ch);
abstract int toUpperCase(int ch);
abstract int toTitleCase(int ch);
abstract int digit(int ch, int radix);
abstract int getNumericValue(int ch);
abstract byte getDirectionality(int ch);
//need to implement for JSR204
int toUpperCaseEx(int ch) {
return toUpperCase(ch);
}
char[] toUpperCaseCharArray(int ch) {
return null;
}
boolean isOtherLowercase(int ch) {
return false;
}
boolean isOtherUppercase(int ch) {
return false;
}
boolean isOtherAlphabetic(int ch) {
return false;
}
boolean isIdeographic(int ch) {
return false;
}
// Character <= 0xff (basic latin) is handled by internal fast-path
// to avoid initializing large tables.
// Note: performance of this "fast-path" code may be sub-optimal
// in negative cases for some accessors due to complicated ranges.
// Should revisit after optimization of table initialization.
static final CharacterData of(int ch) {
if (ch >>> 8 == 0) { // fast-path
return CharacterDataLatin1.instance;
} else {
switch(ch >>> 16) { //plane 00-16
case(0):
return CharacterData00.instance;
case(1):
return CharacterData01.instance;
case(2):
return CharacterData02.instance;
case(14):
return CharacterData0E.instance;
case(15): // Private Use
case(16): // Private Use
return CharacterDataPrivateUse.instance;
default:
return CharacterDataUndefined.instance;
}
}
}
} //假设传参获得的实例是
boolean isJavaIdentifierPart(int ch) {
int props = getProperties(ch);
return ((props & 0x00003000) != 0);
}
int getProperties(int ch) {
char offset = (char)ch;
int props = A[Y[X[offset>>5]|((offset>>1)&0xF)]|(offset&0x1)];
return props;
}
参考资料:http://blog.csdn.net/mazhimazh/article/details/17708001
https://www.zhihu.com/question/20552606
https://baike.baidu.com/item/java%E6%A0%87%E8%AF%86%E7%AC%A6/11010420?fr=aladdin
http://utf8.supfree.net/
说明:本文大部分引用自《Java语言规范-基于Java SE 8》