Java SE Development Kit 7.
1. 对集合的支持.
01.List<String> list =["item"];
02.String item = list[0];
03.Set<String> set ={"item"};
04.Map<String,Integer> map ={"key",1};
05.int value = map["key"];
2. 对资源的自动回收管理
BufferedReader br = new BufferedReader(new FileReader(path));
try{
return br.readLine();}
finally{br.close();}
in 7.0
try (BufferedReader br = new BuferedReader(new FileReader(path));){
return br.readLine();}
3.泛型实例创建过程中类型引用的简化:当声明你的对象的接口时,不需要重复指明泛型类型.
Map<String,String> hello = new Map<>();
4 .对字符串进行switch case
String availability = "available";
switch(availability){
case "available":
//code statement;
break;
case "unavailable":
// code statement;
break;
default:
// code statement;
break;}
7.0前case valueN : valueN的类型必须是与int类型兼容的基本类型,包括byte、short、char.
在7.0中把字符串传进switch case中 需要判断字符串是否为Null值.
5.一个catch里捕捉多个异常类型.
try{
//code statement;
}catch(IOException| NullPointerException|.....){}