Hello everyone,
I have a project to do and my professor wants us to create our own methods that can throw an exception. Not having any idea how to do this I check
Java's official site:
http://java.sun.com/docs/books/tutorial/essential/exceptions/throwing.html I looked at the first example on that page and this something similar to parseExpression(
String) without putting throws ParseException. But the complier gave me an error "unreported Exception".
I reread the criteria that we were given and realized that our professor gave us the method signature for parseExpression(String) and that it included "throws ParseException" at the end. So I added that as you can see in the code and it got rid of the syntax errors.
However when I call the method without putting it inside a try{} it compiles are runs, which it isn't meant to, the compiler should normally tell me "expection must be caught or throw". And thus this method doesn't throw a ParseException when there is an error in String expr's format.
Help please I've only got until the end of this week to complete this.
Thanks in advance.