[update] jdk 10的示例
This commit is contained in:
parent
b29d5741dc
commit
18dfea4d87
3
.gitignore
vendored
3
.gitignore
vendored
@ -33,4 +33,5 @@ build/
|
|||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
*.log
|
*.log
|
||||||
*.class
|
*.class
|
||||||
|
/demo2/java9-example/mods/
|
||||||
|
@ -24,6 +24,7 @@ public class OtherFeaturesExample {
|
|||||||
// Collection.toArray() 新重载方法
|
// Collection.toArray() 新重载方法
|
||||||
List<String> stringList = Arrays.asList("Java", "10", "新特性");
|
List<String> stringList = Arrays.asList("Java", "10", "新特性");
|
||||||
// Java 10新增的重载方法,可以直接指定数组类型
|
// Java 10新增的重载方法,可以直接指定数组类型
|
||||||
|
// String[] stringArray = stringList.toArray(stringList.toArray(new String[0]));
|
||||||
String[] stringArray = stringList.toArray(String[]::new);
|
String[] stringArray = stringList.toArray(String[]::new);
|
||||||
System.out.println("Collection.toArray() 新方法结果: " + Arrays.toString(stringArray));
|
System.out.println("Collection.toArray() 新方法结果: " + Arrays.toString(stringArray));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user