throws name_exception:key word indicates that this methos may throw an exception
throw new .....: creating an exception where it must be throw
![](https://camo.githubusercontent.com/2a48f4040bf1b88867a0c9ec877885cbd55b0ebd4f22e4ed1d469c655415dc2b/68747470733a2f2f696d6775722e636f6d2f554f66767261772e706e67)
class extends fromt the super class Exception
passing the message to be throw in the constructor
![](https://camo.githubusercontent.com/48533da8c7af2a52f0c6eda916c48a8590a5c6b117842874b45418d99aa4732c/68747470733a2f2f696d6775722e636f6d2f44646d396675712e706e67)
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
![](https://camo.githubusercontent.com/86eed7695a3df98a4677da82aaa11d1fec6c67aab4b00a0796c72bfea2ac35c9/68747470733a2f2f696d6775722e636f6d2f796a36357176422e706e67)
![](https://camo.githubusercontent.com/f658e28bf54f47c78f40bfac16c66837238526f122a24efcf5b21830c2b9f6fe/68747470733a2f2f696d6775722e636f6d2f454a73574444302e706e67)