Ask your own question, for FREE!
Computer Science 11 Online
OpenStudy (tsbarker13):

Just trying to teach myself Java. How do I define an exception I can throw -- say I am asking someone to enter an age, but I want to test to see if it is impossible (like < 0, of > 100, then throw an exception to catch the invalid entry?

OpenStudy (anonymous):

You basically just need to extend the Exception class.

OpenStudy (theeric):

There's a lot here for whichever aspects of exception handling interests you: http://docs.oracle.com/javase/tutorial/essential/exceptions/ The link from @seandisanti should help actually write one! This page doesn't really help much at all: http://docs.oracle.com/javase/tutorial/essential/exceptions/creating.html

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!