3 karma · joined Sep 21, 2009 (17y ago) · 1 submissions
comment 15y ago · link · parent
Checked exceptions are not something that I'd happily give up. We do have unchecked exceptions (RuntimeException), and the JRE generally uses them where appropriate. But what about methods like Inflater.inflate, ImageIO.read, or Class.getMethod? If these didn't throw checked exceptions, we would sometimes forget to catch exceptions which should almost always should be caught. It would be a step in the direction of a weaker type system, unhelpful errors, and less graceful recovery.
Regarding initializers, we can do the same thing in Java by giving an initializer block to an anonymous class:
List<Integer> L = new ArrayList<Integer>() {{
for (int i = 0; i < 10; ++i)
add(i);
}};