This content has been marked as final. Show 3 replies
> is generating an error that says "non-static method calc(double)
cannot be referenced from a static context." I don't
understand why I am getting this error.
-- "non-static X cannot be referenced from a static context" --
You get this error because static members don't require an instance of the object to be accessed; they belong to the class. But a non-static member belongs to an instance (an individual object). There's no way for the static method to know which instance's variable to use or method to call, and thus, the compiler happily tells you that you can't access an instance member from a class (static) method.
The Java? Tutorial - Understanding Instance and Class Members