Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Building your own exception class that includes an array

$
0
0
I'm a newbie at Java programming and its just not coming together for me like other languages I've learned.
So hopefully someone here can help. :)

I need to build an Exception class that contains a static public array of valid answers and from this I need to determine if the answer given is valid and if not I will throw the exception.

I tried coding the exception class a few different ways but when I try to code something before super(answer) it gives me an error.

How do I incorporate an array into an exception class?

Any help would be greatly appreciated.

public clase MainException extends Exception
{
public MainException(String answer)
{
**I get an error here if I add anything to test the answer given saying the super("Answer given was incorrect") needs to be first**
super("Answer given was incorrect");
}
{


Thanks.
Nikki

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>