Java : How to find Array list contains Duplicate ?

Introduction

Here we are having the data in the arraylist and if the arraylist contains any duplicate element in that case we need to check the duplicate .

Fix : Store all the ArrayList in the hashset and then check the size of the hashset should be smaller than the arraylist if this is true then duplicate is present

columnname list a arraylist of type String.

Set<String> set=new HashSet<>(columnNameList);
         if(set.size() < columnNameList.size()){
             //if set size is smaller means arraylist contains duplicate
                return true;
            }