JAVA总结--JDK版本区别

jdk1.5的新特性:  1.泛型  2.自动拆箱装箱  3.foreach   4.静态导入(Static import) 此外,枚举、元数据(Metadata)、线程池、Java Generics 

  1、出现泛型

    原来:ArrayList list=new ArrayList(),新特性:ArrayList<Integer>list=new ArrayList<Integer>();

  2、自动装箱/拆箱

    原来:int i=list.get(0).parseInt(),新特性:int i=list.get(0);原始类型与对应的包装类不用显式转换

  3、出现for-each

    原来:while/for/do while ,新特性:for(int i:array)

  4、import static

    原来:import,Math.sqrt(),新特性:import static ,sqrt()

  5、变长参数

    原来:int sum(int int1,int int2,int int3),新特性:方法定义int sum(int ...intlist) ,使用循环遍历intlist,相当于数组

jdk1.6的新特性: 1.Desktop类和SystemTray类     2.使用JAXB2来实现对象与XML之间的映射             3.StAX
        4.使用Compiler API                    5.轻量级Http Server API                     6.插入式注解处理API(Pluggable Annotation Processing API)
        7.用Console开发控制台程序           8.对脚本语言的支持                            9.Common Annotations

  1、增强的for循环语句

    原来:Integer[] n = getn();for (int i=0; i < n.length ; i++),新特性:for (int i=0; i < getn().length ; i++),初始化表达式仅一次

  2、

    

jdk1.7的新特性: 1 对集合类的语言支持;    2 自动资源管理;    3 改进的通用实例创建类型推断;      4 数字字面量下划线支持; 
        5 switch中使用string;    6 二进制字面量;    7 简化可变参数方法调用。 

原文地址:https://www.cnblogs.com/huasky/p/7649460.html