jdk1.6 和 jdk1.7 区别

1、JDK1.6 以前的版本只支持 byte、char、short、int、枚举,

      JDK1.7 增加 String 类型

2、运用 List<String> tempList = new ArrayList<>(); 即泛型实例化类型自动推断
   (1)在以前的版本中使用泛型类型,需要在声明并赋值的时候,两侧都加上泛型类型。例如:
Map<String, String> myMap = new HashMap<String, String>();
(2)在Java SE 7中,这种方式得以改进,现在你可以使用如下语句进行声明并赋值:
Map<String, String> myMap = new HashMap<>();    //注意后面的"<>"
语法上支持集合,而不一定是数组
final List<Integer> lists= [ 1,2,3,4,5,6];
新增一些取环境信息的工具方法
File System.getJavaIoTempDir() // IO临时文件夹

File System.getJavaHomeDir() // JRE的安装目录

File System.getUserHomeDir() // 当前用户目录

File System.getUserDir() // 启动java进程时所在的目录5

switch中可以使用字串

String s = "test";   
switch (s) {   
  case "test" :   
     System.out.println("test");  
  case "test1" :   
    System.out.println("test1"); 
    break ;   
  default :   
    System.out.println("break"); 
    break ;   
 } 

数字字面量下划线支持 
      很长的数字可读性不好,在Java 7中可以使用下划线分隔长int以及long了,如: 
         int one_million = 1_000_000; 
   运算时先去除下划线,

如:1_1 * 10 = 110,120 – 1_0 = 110 



猜你喜欢

转载自www.cnblogs.com/proyuan/p/11915760.html