title: Print the value of a Point to the terminal
body: <p>I created a class that can find the distance between two points and the value of the midpoint between them:</p>
  
  <pre><code>public class Point {
  
      private double x;
      private double y;
  
      public Point (double x, double y) {
  
          this.x = x;
          this.y = y;
      }
  
      public double getX() {
          return x;
      }
  
      public void setX(double x) {
          this.x = x;
      }
  
      public double getY() {
          return y;
      }
  
      public void setY(double y) {
          this.y = y;
      }
  
      public static void main (String[] args) {
          Point p1 = new Point(1,1);
          Point p2 = new Point(4,5);
          System.out.println("The distance between p1 and p2 is: " + distance(p1, p2));
          System.out.println("The midpoint of p1 and p2 is: " + findMidpoint(p1, p2));
      }
  
      public static double distance(Point p1, Point p2) {
           return Math.sqrt((p1.getX() - p2.getX()) *  (p1.getX() - p2.getX()) + 
                            (p1.getY() - p2.getY()) *  (p1.getY() - p2.getY()));
      }
  
      public static Point findMidpoint (Point p1, Point p2) {
          return new Point((p1.getX() + p2.getX()) / 2, (p1.getY() + p2.getY()) / 2);
      }
  }
  </code></pre>
  
  <p>This code compiles fine but when I run it, it gives the output:</p>
  
  <pre><code>The distance between p1 and p2 is: 5.0
  The midpoint of p1 and p2 is: Point@15db9742
  </code></pre>
  
  <p>It gives the same value for the midpoint regardless of the values of p1 and p2. I want to output the midpoint in the format "<strong>(x,y)</strong>".</p>
  
  <p>Could somebody also explain why I was forced to make the distance and findMidpoint methods static?</p>