title: Java Array List - finding duplicate in While loop
body: <p>I tried solving this ArrayList problem but no luck</p>
  <p>Anyway in while loop I have to add new String items to the ArrayList.</p>
  <p>If there is a duplicate item there should be a message that says REPEATED ITEM.</p>
  <p>While loop will break by word END</p>
  <pre><code>public static void main(String[] args) {
      
      ArrayList&lt;String&gt; lista1 = new ArrayList&lt;&gt;();
      Scanner in = new Scanner(System.in);
      
      while(true) {
          System.out.println(&quot;enter words: &quot;);
          lista1.add(in.nextLine());
          if(lista1.containsAll(lista1)){
              System.out.println(&quot;Repeated words&quot;);
          }
          if(lista1.contains(&quot;end&quot;)) {
              break;
          }
      }
  
      for(String data:lista1)
          System.out.println(data);
  }
  </code></pre>