我刚刚在看一篇关于编程的教程,发现了一个有趣的东西——JDK 5中引入的import static
功能:
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中最具有变革性的功能的简短列表。