title: Override equals method in java
body: <p>Let's consider the following simple class.</p>
  
  <pre><code>class Point {
  private float x;
  private float y;
  
  public Point(float x, float y){
      this.x=x;
      this.y=y;
  }
  
  public float getX(){return this.x;}
  public float getY(){return this.y;}
  public void setX(float x){this.x=x;}
  public void setY(float y){this.y=y;}
  
  @Override
  public String toString(){
      return ("x = "+this.x+", y = "+this.y+";");
  }
  @Override
  public Point clone(){
      return new Point(this.x,this.y);
  }
  @Override
  public boolean equals(Object object){
      if (object != null &amp;&amp; object.getClass()==Point.class){
          return object.getX()==this.x &amp;&amp; object.getY()==this.y;
      }
      else{
          return false;
      }
  }
  </code></pre>
  
  <p>The problem is in the rewrite of method equals: i use the general Object class as attribute to make it more flexible, but netbeans prints error on return line: "Object has no method getX" wich is perfectly logical. </p>
  
  <p>But the problem is still here, how can i manage to fix this ?</p>
  
  <p>Thanks you in advance :)</p>