title: Deleting a class object in java
body: <p>I have a class named <code>Point</code> as below:</p>
  
  <pre><code>public class Point {
      public int x;
      public int y;
  
      public Point(int X, int Y){
          x = X;
          y = Y;
      }
  
      public double Distance(Point p){
          return sqrt(((this.x - p.x) * (this.x - p.x)) + ((this.y - p.y) * (this.y - p.y)));
      }
  
      protected void finalize()
      {
          System.out.println( "One point has been destroyed.");
      } 
  }
  </code></pre>
  
  <p>I have an object from this class named <code>p</code> as below:</p>
  
  <pre><code>Point p = new Point(50,50);
  </code></pre>
  
  <p>I want to delete this object, I searched how to do it, the only solution I found was:</p>
  
  <pre><code>p = null;
  </code></pre>
  
  <p>But the finalize method of Point didn't work after I did it. What can I do?</p>