title: LinkedHashSet .equals() vs LinkedList .equals() with same elements but different order
body: <p>Consider the following SSCCE:</p>
  
  <pre><code>public static void main(String[] args) {
      LinkedHashSet&lt;String&gt; set1 = new LinkedHashSet&lt;&gt;();
      set1.add("Bob");
      set1.add("Tom");
      set1.add("Sam");
      LinkedHashSet&lt;String&gt; set2 = new LinkedHashSet&lt;&gt;();
      set2.add("Sam");
      set2.add("Bob");
      set2.add("Tom");
  
      System.out.println(set1);
      System.out.println(set2);
      System.out.println(set1.equals(set2));
  }
  </code></pre>
  
  <p>This prints:</p>
  
  <pre><code>[Bob, Tom, Sam]
  [Sam, Bob, Tom]
  true
  </code></pre>
  
  <p>Yet if you change <code>LinkedHashSet</code> to <code>LinkedList</code>:</p>
  
  <pre><code>public static void main(String[] args) {
      LinkedList&lt;String&gt; set1 = new LinkedList&lt;&gt;();
      set1.add("Bob");
      set1.add("Tom");
      set1.add("Sam");
      LinkedList&lt;String&gt; set2 = new LinkedList&lt;&gt;();
      set2.add("Sam");
      set2.add("Bob");
      set2.add("Tom");
  
      System.out.println(set1);
      System.out.println(set2);
      System.out.println(set1.equals(set2));
  }
  </code></pre>
  
  <p>it produces:</p>
  
  <pre><code>[Bob, Tom, Sam]
  [Sam, Bob, Tom]
  false
  </code></pre>
  
  <p>My question is one of clarification. Can someone help make sense of this? Why would a <code>LinkedHashSet</code> be considered equals whereas the same <code>LinkedList</code> would not? I'm assuming the definition of <code>List</code> and <code>Set</code> plays a role, but I'm not sure.</p>
  
  <p>Basically, I'm saying if you consider the <code>Set</code>s to be the same, wouldn't you consider the <code>List</code>s to be the same too? And vice-versa (assuming no duplicate elements)?</p>