K
kaja_love160
Hello
Book I’m learning from claims that exceptions of type RuntimeException
and its children are thrown due to bad programming and should be
avoided by writing better code. One such exception of type
RuntimeException might happen when a user is asked to enter a value
and user enters an invalid value ïƒ this may cause runtime exception.
We can go about it in two ways:
1) by writing "if ( correct input ) .. else"
2) or by throwing and catching an exception
Now according to my book ( as I understood it ) we should use
something like : if ( correct input ) .. else “ to deal with this
problem and not use exceptions. Why shouldn’t exceptions be used for
such cases?
Thank you
Book I’m learning from claims that exceptions of type RuntimeException
and its children are thrown due to bad programming and should be
avoided by writing better code. One such exception of type
RuntimeException might happen when a user is asked to enter a value
and user enters an invalid value ïƒ this may cause runtime exception.
We can go about it in two ways:
1) by writing "if ( correct input ) .. else"
2) or by throwing and catching an exception
Now according to my book ( as I understood it ) we should use
something like : if ( correct input ) .. else “ to deal with this
problem and not use exceptions. Why shouldn’t exceptions be used for
such cases?
Thank you