How to check for value equality?
<p>I'm a Java-beginner, so please bear with this one.</p>

<p>I have a class:</p>

<pre><code>class Point {
  public int x;
  public int y;

  public Point (int x, int y) {
    this.x = x;
    this.y = y;
  }
}
</code></pre>

<p>I create two instances:</p>

<pre><code>Point a = new Point(1, 1);
Point b = new Point(1, 1);
</code></pre>

<p>I want to check if these two points are at the same place. The obvious way, <code>if (a == b) { ... }</code>, does not work since this seems to be an "are the <em>objects</em> equal?" kind of test, which is not what I want.</p>

<p>I can do <code>if ( (a.x == b.x) &amp;&amp; (a.y == b.y) ) { ... }</code>, but that solution does not feel good.</p>

<p>How can I take two Point-objects and test them for equality, coordinate wise, in an elegant way?</p>
