title: Why is set.contains not using overriden equals() method?
body: <p>I have a class like this:</p>
  
  <pre><code>class Vertex {
      char v;
      char w;
      int cost;
  
      public Vertex(char v, char w, int cost){
          this.v = v;
          this.w = w;
          this.cost = cost;
      }
  
      @Override
      public String toString(){
          return "["+v+" "+w+" "+cost+"]";
      }
  
      @Override
      public boolean equals(Object o) {
          if (this == o) return true;
          if (o == null || getClass() != o.getClass()) return false;
          Vertex vertex = (Vertex) o;
          return (v == vertex.v &amp;&amp; w == vertex.w) || (w == vertex.v &amp;&amp; v == vertex.w);
      }
  
      @Override
      public int hashCode() {
          return Objects.hash(v, w);
      }
  }
  </code></pre>
  
  <p>I am trying to have the <code>equals()</code> return true when two vertexes are equal or opposite equal. Meaning it should return true if there is a vertex (v,w) and (w,v).</p>
  
  <p>My <code>equals()</code> is symmetric and reflexive as it should be, but still the <code>set.contains()</code> return false for (v,w) and (w,v) case.</p>
  
  <p>I would appreciate any help.</p>