1, In the development work , We need to judge sometimes List Does the collection contain duplicate elements
2, We don't need to find repetitive elements , We just need to return one Boolean Type is OK
3, If you use loop traversal , Will consume a lot of performance
4, We know ,Set There are no duplicate data stored in , So you just need to List Set to Set aggregate , Then compare them

The code is as follows :
package com.test; import java.util.ArrayList; import java.util.HashSet; import
java.util.List; public class Test { public static void main(String[] args) { //
Define a list aggregate List<String> list = new ArrayList<String>(); // to list Add data to it list.
add("a"); list.add("b"); list.add("a"); list.add("c"); // take list Into set HashSet
<String> set = new HashSet<>(list); // compare list And set Length of Boolean result = set.
size() == list.size() ? true : false; // Output comparison results System.out.println(result); } }
The result is, of course :false

If you find a deficiency in your reading , Welcome to leave a message !!!

Technology
©2020 ioDraw All rights reserved
Sharing a script of hacker empire code rain , Simple and fun !-bash The Trojan horse , Have you ever met one ?k8s delete pod Zhejiang University data structure midterm examination questions Detailed explanation PHP Medium die,exit,returnlayui.table Examples of dynamically getting header and list data Interview questions : Handwritten list ( Include reverse linked list ) After the outbreak Which programming has a bright future PTA Quick sort Ctrip 2019 School recruitment LRU Cache