jdk7和8的一些新特性介绍 (三)
onEvent event) {
System.out.println("Hello World!");
}
});
jdk8直接可以这么写:
btn.setOnAction(
event -> System.out.println("Hello World!")
);
更多示例:
public class Utils {
public static int compareByLength(String in, String out){
return in.length() - out.length();
}
}
public class MyClass {
public void doSomething() {
String[] args = new String[] {"microsoft","apple","linux","oracle"}
Arrays.sort(args, Utils::compareByLength);
}
}
13.jdk8的一些其他特性,当然jdk8的增强功能还有很多,大家可以参考http://openjdk.java.net/projects/jdk8/
用Met
aspace代替PermGen
动态扩展,可以设置最大值,限制于本地内存的大小
Parallel array sorting 新APIArrays#parallelSort.
New Date & Time API
Clock clock = Clock.systemUTC(); //return the current time based on your system clock and set to UTC.
Clock clock = Clock.systemDefaultZone(); //return time based on system clock zone
long time = clock.millis(); //time in milliseconds from January 1st, 1970