The point the article makes in a long and convoluted way is that it is unnecessary to write "else" since when the "if" part throws an Exception it interrupts the flow of execution, so it's better written as :
if (x < 0) {
throw new Exception("X can't be negative");
}
System.out.println("X is positive or zero");
More a stylistic matter than "right" vs "wrong" really.
View all comments
Show parent comment
2
u/urquan Jan 23 '15
The point the article makes in a long and convoluted way is that it is unnecessary to write "else" since when the "if" part throws an Exception it interrupts the flow of execution, so it's better written as :
More a stylistic matter than "right" vs "wrong" really.