title: Find duplicate value in array list and print the duplicated value
body: <p>I have an Arraylist of names, I want to see duplicated values if exist and print this value. The problem is that I'm getting confused on whether to use contains method or not, the below code is not working.</p>
  
  <pre><code>ArrayList&lt;String&gt; list=new ArrayList();
          list.add("Sagio Mane");
          list.add("Karius");
          list.add("Mo Salah");
          list.add("Firmino");
          list.add("Lovren");
          list.add("Steven Gerrard");
          list.add("Karius");
          list.add("Mo Salah");
  
      for(int i =0; i &lt; list.size(); i++) {
           if list.contains(list.get(i)) {
               System.out.println(list.get(i)+" is duplicated")
           }
      }
  </code></pre>
  
  <p>This should print "karius is duplicated"</p>