说明: creating a date class and throw an exception if it s an invalid one, stars:1, update:2024-04-15 19:24:59
# Date-exception
Date
throws name_exception:key word indicates that this methos may throw an exception
throw new .....: creating an exception where it must be throw
DException
class extends fromt the super class Exception
passing the message to be throw in the constructor
Test
main class where to test the code
try: keyword to execute a bloc of code if there is no error
catch: to throw an exception in case of error
Screen shot of execution