java7新特性

1、switch语句中可以使用字符串

	switch(week){
	case:"Monday"
	break;
}
2、处理不同的异常

try {
			File file = new File("");
			FileInputStream inputStream = new FileInputStream(file);
			SimpleDateFormat format = new SimpleDateFormat();
			format.parse("");
		} catch (FileNotFoundException|ParseException e) {
			e.printStackTrace();
		}

3、try-with-resources(TWR),资源自动化管理,不用再手动去关闭资源。
                File file = new File("");
		try(FileInputStream inputStream = new FileInputStream(file);
				ObjectInputStream ois = new ObjectInputStream(inputStream)) {
			System.out.println(inputStream);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} 



你可能感兴趣的:(java,进阶)