3 Replies Latest reply on Feb 27, 2007 1:49 PM by 807599

    non-static method cannot be referenced from static context

      In the following code I am making a call to method calc. ( I put the service class and the main class in the same file for simplicity ). The code line that says
      result = calc(4);
      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.
      class Example5 {
         int denom = 2;
         public static void main(String [] args) {
            double result;
            result = calc(4);
         public double calc(double num) {
            return (num * num) / denom;