+ 3
Are you irked that Java can't figure out what exceptions are thrown simply from the "throw" statements in the block, and so requires the use of "throws" declarations?
Yeah me too. /snark
7 ответов
+ 1
The key to programming, is knowing when something might throw an exception and coding based off that knowledge. Otherwise, you're essentially blindly letting your code do run.
+ 1
@James I understand the utility of explicit "throws" declarations to method clients when the throw is implicit i.e. resulting from some operation like a div by zero or null ref. My point is that using an explicit "throw" statement is a pretty clear indication to the compiler that an exception is possible i.e. it *implies* the "throws" statement. In my humble opinion, the compiler ought to be able to provide the "throws" information to clients in such cases (other languages do this). I just find it a little annoying is all. I'm sure I'll get over it. 😀
+ 1
Never played with another language that did what you're saying, so don't have that gripe yet :)
and I just realized what you meant in your original grunt so my response was off base there. My bad. gripe away :D
+ 1
Actually...
If someone else writes code that uses that method, it gives them an indication of what exception it might throw, without them having to read the code.
So a good thing for reusability and maintenance.
0
I suppose that it makes the code cleaner and more maintainable. You know while reading the code which methods may throw an exception and when it is catched,without reading the whole methods
0
hai bro my name is hendra from indonesia
0
i love java programming leangue SE, EE or android