import java.util.*; public class CheckDuplicates { public static boolean hasDuplicates(List stringList) { if (stringList == null || stringList.isEmpty()) return false; Set stringSet = new HashSet<>(); for (String str : stringList) { if (!stringSet.add(str)) { return true; // Duplicate found } } return false; } public static void main(String[] args) { List stringList = Arrays.asList("apple", "banana", "cherry", "apple"); System.out.println("Has Duplicates: " + hasDuplicates(stringList)); } }