刚才在看一个代码教程,发现了一些有趣的东西import static
——JDK 5 中引入的特性:
import static org.junit.Assert.assertEquals;
public class AdditionTest {
private int x = 1;
private int y = 1;
@Test public void addition() {
int z = x + y;
assertEquals(2, z);
/* ^ this is a static method, normally called by Assert.assertEquals */
}
}
这让我想知道,JDK 5 和 6 中还引入了哪些我不知道的其他特性?还有其他类似的新关键字用法吗?任何值得注意的新库类或函数?
我知道发行说明或变更日志在那里,我不是在寻找“RTFM”的答案。我想知道您认为 JDK 5 或 6 中最能改变游戏规则的功能的简短列表。