title: call a method in class, inheritance
body: <p>I have a problem, the solution is probably very easy, but nothing comes to mind at the moment, so I am looking for a little help.</p>
  <p>... so I have a problem with calling the method.</p>
  <p>I have a Space 2D class:</p>
  <pre><code>    public class Space2D {
      
      //several other methods etc.
      
      //for example I will take this method
  
      public double distance(Space2D p1, Space2D p2) {
              double dx = p1.x - p2.x;
              double dy = p1.y - p2.y;
              return Math.sqrt(dx * dx + dy * dy);
          }
      }
  </code></pre>
  <p>and I want to call it in the SpaceTest class:</p>
  <pre><code>public class SpaceTest extends Space3D {
      public static void main(String[] args) {
      Space2D point2D = new Space2D();
  
      // I also have a Space 3D class that inherits from the 2D class.
      // but I want to call the distance method from the Space 2D class so I'll try to do it like this:
  
      point2D.distance(3,4) // &lt;-- wrong 
  
     }
  }
  </code></pre>
  <p>I would like to put 3 and 4 after p1 and p2 from the distance method but I get a bug that I have to put integers in it if I want to do so, so my question what do I have to put in calling this method so that I can run it, i.e. what do I have to put for this object ?? &quot;Space2D p1&quot;?
  point2D.distance (???)</p>
  <p>Thank you in advance for your help and explanation, I hope you will help me understand this.</p>