Serializable, Comparable<SourceVersion>public enum SourceVersion extends Enum<SourceVersion>
Note that additional source version constants will be added to model future releases of the language.
| 枚举常量 | 说明 |
|---|---|
RELEASE_0 |
The original version.
|
RELEASE_1 |
The version recognized by the Java Platform 1.1.
|
RELEASE_2 |
The version recognized by the Java 2 Platform, Standard Edition,
v 1.2.
|
RELEASE_3 |
The version recognized by the Java 2 Platform, Standard Edition,
v 1.3.
|
RELEASE_4 |
The version recognized by the Java 2 Platform, Standard Edition,
v 1.4.
|
RELEASE_5 |
The version recognized by the Java 2 Platform, Standard
Edition 5.0.
|
RELEASE_6 |
The version recognized by the Java Platform, Standard Edition
6.
|
RELEASE_7 |
The version recognized by the Java Platform, Standard Edition
7.
|
RELEASE_8 |
The version recognized by the Java Platform, Standard Edition
8.
|
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
static boolean |
isIdentifier(CharSequence name) |
Returns whether or not
name is a syntactically valid
identifier (simple name) or keyword in the latest source
version. |
static boolean |
isKeyword(CharSequence s) |
Returns whether or not
s is a keyword or literal in the
latest source version. |
static boolean |
isName(CharSequence name) |
Returns whether or not
name is a syntactically valid
qualified name in the latest source version. |
static SourceVersion |
latest() |
Returns the latest source version that can be modeled.
|
static SourceVersion |
latestSupported() |
Returns the latest source version fully supported by the
current execution environment.
|
static SourceVersion |
valueOf(String name) |
返回带有指定名称的该类型的枚举常量。
字符串必须与用于声明该类型的枚举常量的
标识符完全匹配。(不允许有多余
的空格字符。)
|
static SourceVersion[] |
values() |
按照声明该枚举类型的常量的顺序, 返回
包含这些常量的数组。该方法可用于迭代
常量, 如下所示:
for (SourceVersion c : SourceVersion.values()) System.out.println(c); |
public static final SourceVersion RELEASE_0
public static final SourceVersion RELEASE_1
RELEASE_0 augmented with nested classes as described in the 1.1 update to
The Java™ Language Specification, First Edition.public static final SourceVersion RELEASE_2
strictfp modifier.public static final SourceVersion RELEASE_3
RELEASE_2.public static final SourceVersion RELEASE_4
public static final SourceVersion RELEASE_5
for loop, and hexadecimal floating-point literals.public static final SourceVersion RELEASE_6
RELEASE_5.public static final SourceVersion RELEASE_7
try-with-resources, strings in switch,
binary literals, and multi-catch.public static final SourceVersion RELEASE_8
public static SourceVersion[] values()
for (SourceVersion c : SourceVersion.values()) System.out.println(c);
public static SourceVersion valueOf(String name)
name - 要返回的枚举常量的名称。IllegalArgumentException - 如果该枚举类型没有带有指定名称的常量NullPointerException - 如果参数为空值public static SourceVersion latest()
public static SourceVersion latestSupported()
RELEASE_5 or later must
be returned.public static boolean isIdentifier(CharSequence name)
name is a syntactically valid
identifier (simple name) or keyword in the latest source
version. The method returns true if the name consists
of an initial character for which Character.isJavaIdentifierStart(int) returns true,
followed only by characters for which Character.isJavaIdentifierPart(int) returns true.
This pattern matches regular identifiers, keywords, and the
literals "true", "false", and "null".
The method returns false for all other strings.name - the string to checktrue if this string is a
syntactically valid identifier or keyword, false
otherwise.public static boolean isName(CharSequence name)
name is a syntactically valid
qualified name in the latest source version. Unlike isIdentifier, this method returns false
for keywords and literals.name - the string to checktrue if this string is a
syntactically valid name, false otherwise.public static boolean isKeyword(CharSequence s)
s is a keyword or literal in the
latest source version.s - the string to checktrue if s is a keyword or literal, false otherwise.