• Post Reply Bookmark Topic Watch Topic
  • New Topic

non-static method error  RSS feed

 
Rick Horn
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do I need to change to make this work? I'm getting non-static error, as well as constructor cannot be applied to given type...i've read up on this but cannot figure it out



Verify Class:



Number High:



Number Low:



Negative:



 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would suggest that throwing a checked Exception may be a bit of overkill. If your Exception extends plain simple Exception then it is checked. Maybe making your Exception extend IllegalArgumentException is an alternative strategy; then it will be unchecked.

Another alternative strategy is to change that method so it returns a boolean. I shall leave it to you, but give you a hintThen you can use it in a loop like this
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have got some confusion in your Exception classes and in your Verify class about how you set fields from parameters.
 
Knute Snortum
Sheriff
Posts: 4288
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm getting non-static error, as well as constructor cannot be applied to given type.


In this code:

You're calling validate() in a static way, but is the method static? Should it be?

In this code:


You're calling NumberLowException's constructor. Does it have a one argument constructor? Should it?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!