Checked exceptions thrown from within lambda expressions
问题 Can you please explain why checked exceptions have to be caught from within lambda expressions? In other words, why does the following code not compile... public void doSomething(ObjectInputStream istream) throws IOException { // The read method throws an IOException. IntStream.range(0, 10).forEach(i -> someList.add(read(istream))); } but this one will? public void doSomething(ObjectInputStream istream) throws IOException { IntStream.range(0, 10).forEach(i -> { try { // The read method throws