Seriously, Java doesn't force bad programmers to write good code. It just enables good programmers to write good code.
Also, imagine a situation when an iterator throws an exception. Or you wanted to write f(g()) but now you can't and have to do:
try:
T t = g();
catch E1:
...
catch En:
...
f(t);
Now it takes a much greater effort for the reader to figure out what's going on. It's also tempting to allow some exception cases to succeed so, f(t) is reached even if there was an error. Because these two code pieces are now far apart, it's possible that later edits will introduce bugs because the programmer didn't see that either f(t) is reachable even if g() failed, or accidentally made it reachable when it shouldn't have been.Bottom line, it makes human errors more likely.
try {
final var fResult = f(g());
//do something with fResult
}catch (E1 e) {...}
catch (En e) {...}
That's the main idea of exceptions in all languages: main flow is kept together and exceptional flows are separate.
No... I don't think so.
Checked Exceptions are at best, just a 'hey, are you sure that's right thing to do here?' and at worst, an additional source of rigidity in your code that blows up the scale of a minor change.
Right, and that was my point at the top post in this thread.
I will also cede the point that you can write good code in Java.
But my point was that Java wouldn't have enforced the situation to be a compile error, not that you can't write good code in Java. I maintain this point, and I think it's true for the average java project.
If you're getting these benefits from Java, it's the intersection of Java and your team's or your organization's culture, not purely from Java. It's possible for you to gain this benefit and for checked exceptions to have still failed out in the wider world of the average Java project.