1:增强的“for”循环 
    List list = new ArrayList();
    FeatureValueVO vo = null;
     for ( int i = 0; i < 10; i++) {
      vo = new FeatureValueVO();
      vo.setClassifyFeatureId(111);
      list.add(vo);
    }
     // 增强的FOR循环
     for (FeatureValueVO temp : list) {
      System.out.println(temp.getClassifyFeatureId());
    }
 
2:自动装箱、拆箱
     // 自动 装箱、拆箱
    List list = new ArrayList();
    list.add(1);
    Integer it = list.get(0);
    System.out.println(it == 1);
 
3:类型安全的枚举
先创建一个枚举类型类:
package jdk15;

public enum Operation {
  PLUS {
     double eval( double x, double y) {
       return x + y;
    }
  },
  MINUS {
     double eval( double x, double y) {
       return x - y;
    }
  },
  TIMES {
     double eval( double x, double y) {
       return x * y;
    }
  },
  DIVIDE {
     double eval( double x, double y) {
       return x / y;
    }
  };

   // Do arithmetic op represented by this constant
   abstract double eval( double x, double y);
}
应用上面创建的类:
     // 类型安全的枚举
     double d1 = 1.22;
     double d2 = 2.11;
     for (Operation op : Operation.values()) {
      System.out.println( "d1 " + op + " d2=" + op.eval(d1, d2));
    }
 
4:静态导入
在文件开头添加静态导入:
import static java.lang.System.*;
import static java.lang.Math.*;
应用静态导入:
     // 静态导入
    out.println( "good job!");
    out.println(abs(-1.222));
 
5:可变参数
   private static int sum( int... nums) {
     int total = 0;
     for ( int i : nums) {
      total += i;
    }
     return total;
  }
调用该方法:
     // 可变参数
    System.out.println(sum(1, 2, 3, 4, 5, 6));
 
6:注释annotation
应用1:
首先创建一个注释类:
package jdk15;

public @ interface Info {
  String author() default "good";
}
应用该注释:
   private @Info void test6(){
  }
    
   private @Info(author= "goodjob") void test7(){
  }
 
应用2:
创建作者注释:
package jdk15;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@Retention(RetentionPolicy.RUNTIME)
public @ interface Author {
   public enum Gender {
    MALE, FEMALE
  };

  String name();

  String email();

  Gender gender() default Gender.MALE;
}
说明标签的四种取值:
Target:指明注释可以在哪些代码段中使用,以避免对注释的误用。
Retention:说明编译器在编译和运行时是否忽略该种注释
Documented:说明注释是否出现在Javadoc中
Inherited:是否继承
 
创建TODO注释:
package jdk15;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@Retention(RetentionPolicy.RUNTIME)
public @ interface Todo {
  String value();
}
 
应用上面创建的两个注释:
package jdk15;

public @Todo( "delete ok")
class Foo {
   public void methodA() {
  }

   public @Author(name = "B", email = "[email][email protected][/email]")
   void methodB() {

  }

   public @Author(name = "A", email = "[email][email protected][/email]")
  String fieldA;

}
 
获取指定类的注释信息:
package jdk15;

import java.lang.reflect.Method;

public class GetAnnotations {
   public static void main(String[] args) {
     try {
      String name = "jdk15.Foo";
      Class klass = Class.forName(name);
       if (klass.isAnnotationPresent(Todo. class)) {
        Todo t = klass.getAnnotation(Todo. class);
        System.out.println(t);
      }

       for (Method m : klass.getMethods()) {
         if (m.isAnnotationPresent(Author. class)) {
          Author a = m.getAnnotation(Author. class);
          System.out.printf( "Method:%s,Author:%s%n", m.getName(), a);
        }
      }
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    }
  }
}
控制台输出结果如下:
@jdk15.Todo(value=delete ok)
Method:methodB,Author:@jdk15.Author(gender=MALE, name=B, [email protected])
关于注释可以参考 SUN的说明文档