title: How to calcualate the distance between two Object of a class which have 3 coordinates points?
body: <p>This is my class 3DObj in 3DObj.java.</p>
  
  <pre><code>public class 3DObj {
      private double a;
      private double b;
      private double c;
      public double dist;
  
      public 3DObj() {
  
      }
  
      public 3DObj(double a, double b, double c) {
          this.a = a;
          this.b = b;
          this.c = c;
  
      }
      public double getA() {
          return a;
      }
      public double getB() {
          return b;
      }
      public double getC() {
          return c;
      }
  
      public double dist(3DObj p1, 3DObj p2, 3DObj p3) {
          dist = Math.sqrt(Math.pow((p2.a - p1.a), 2)
                           + Math.pow((p2.b - p1.b), 2) 
                           + Math.pow((p2.c - p1.c), 2));
          return dist;
      }
  
      public double getDist() {
          return dist;
      }
  }
  </code></pre>
  
  <p>Below is my 3DObjTest class in 3DObjTest.java</p>
  
  <pre><code>public class 3DObjTest {
      public static void main(String[] args) {
          3DObjTest 3DObj1 = new 3DObj(2.5, 2.5, 2.5);
          3DObjTest 3DObj2 = new 3DObj(2.0, 2.2, 3.0);
          System.out.println("Distance is " + 3DObj1.getDist());
      }
  }
  </code></pre>
  
  <p>but it is only showing 0.0 instead of any other number.</p>
  
  <p>How can I calculate the distance between 3DObj1 and 3DObj2?</p>