java7 新特性

虽然JDK8都发布了,但是JDK7的新特性还是自己总结一下吧!  

1 二进制字面量(0b/0B)

         int x = 0b0101011;
        
         System.out.println(x);  43

2 数字字面量可以出现下划线(方便阅读)

          int x = 1_9999_8888;

          注意:不能出现在进制标识与数值之间 0x_11_22
                不能出现在数值的开头和结尾   _111   111_
                不能出现在小数点叛变        3._14

3 swicth  可能出现字符串   可能支持的类型 byte short int char string

4  泛型的简化   List<String> j = new ArrayList<>();

5  多个catch的合并

try-with-resources 语句
   
    try(AutoCloseable的子类){}catch(){}
    资源自动释放,不需要close

   




               

猜你喜欢

转载自whnqwe.iteye.com/blog/2293839