diamond operator.
泛型只需要在泛型声明时声明具体类型,如:
List list=new ArrayList<>();
注意 必须带<>符号。using primitive,enum or string in switch statements.
switch语句支持string,比较时使用equalautomatic resource management
notice that the resource should be managed automaticly must implement java.lang.AutoCloseable interface.
the AutoCloseable is the parent of java.io.Closeable interface and has just one method close() that would be called by jvm when the control comes out of the try block.
try语句自动支持对资源对象的回收管理,这些资源对象必须实现AutoCloseable接口,如 java.io.Closeable
the code template like this :
try(
InputStream readIn=new FileInputStream(path);
OutputStream writeOut=new FileOutputStream(otherPath)
){
// doSmothing
}numeric literals with underscores
notice that the binary literals are also release too.
数字字面量可以使用下划线隔开,二进制字面量也直接支持,如:
1_000_000
0b1001improved exception handling.
在catch语句参数中可以捕获多个异常类型,每个异常类型通过符号 | 隔开new file system api(nio 2.0).
(1) working with path:a new java.nio.file package consists of classes and interfaces such as path,paths,files,FileSystems and others.
(2) file change notifications:
a. create a WatchService,the service consists of a queue to hold watchkeys.
b. register the director/file you wish to monitor with this WatchService.
c. while registering,specify the types of events you wish to receive(create,modify,delete events).
d. when an events occurs,a watchkey is placed into the queue.fork and join
ForkJoinPool,RecursiveAction,RecursiveTask.
java 7 new feature
最新推荐文章于 2019-12-08 16:10:23 发布