title: Calculating the distance between two points
body: <p>I need to create a class which calculates the distance between two points. I am stuck and I am a total beginner. Here are my classes:</p>
  
  <pre><code>package org.totalbeginner.tutorial;
  
  public class Point {
  
      public double x;
      public double y;
  
      Point(double xcoord, double ycoord){
          this.x = xcoord;
          this.y = ycoord;
      }
  
      public double getX() {
          return x;
      }
  
      public double getY() {
          return y;
      }    
  }
  </code></pre>
  
  <p>The second class.</p>
  
  <pre><code>package org.totalbeginner.tutorial;
  
  public class Line {
  
      double x;
      double y;
  
      Point p1 = new Point(2.0,2.0);
      Point p2 = new Point(4.0,4.0);
      Point mp = new Point(x,y);
  
      public void midpoint() {
          x = (p1.getX() + p2.getX()) / 2;
          y = (p1.getY() + p2.getY()) / 2;
      }
  }
  </code></pre>
  
  <p>I am not sure how to get a point object (the middle point) between both defined points.</p>
  
  <p>I can create point objects but I am not sure how to return a point object through my <code>midpoint()</code> method that lies between those two point objects.</p>