package com.mayikt.stream;  import com.mayikt.entity.UserEntity;  import java.util.ArrayList; import java.util.Set; import java.util.function.Consumer; import java.util.stream.Collectors; import java.util.stream.Stream;  /**  * @ClassName Test01  * @Author 螞蟻課堂余勝軍 QQ644064779 www.mayikt.com  * @Version V1.0  **/ public class Test01 {     public static void main(String[] args) {         ArrayList userEntities = new ArrayList<>();         userEntities.add(new UserEntity("mayikt", 20));         userEntities.add(new UserEntity("meite", 28));         userEntities.add(new UserEntity("zhangsan", 35));         /**          * user 對象屬性值都是相等的 但是new 兩個對象 這兩個對象的 內(nèi)存地址 是不一樣的          */ //        UserEntity user = new UserEntity("xiaowei", 16); //        userEntities.add(user); //        userEntities.add(user);         userEntities.add(new UserEntity("xiaowei", 16));         userEntities.add(new UserEntity("xiaowei", 16));         userEntities.forEach((t) -> {             System.out.println(t.toString());         });         System.out.println("取出重復(fù)..."); //        /** //         * 創(chuàng)建stream方式兩種 //         * 1.串行流stream() 單線程 //         * 2.并行流parallelStream() 多線程 //         * 并行流parallelStream 比串行流stream()效率要高的 //         */         Stream stream = userEntities.stream();         // 轉(zhuǎn)換成set集合         Set setUserList = stream.collect(Collectors.toSet());         setUserList.forEach(userEntity -> {             System.out.println(userEntity.toString());         });                   } }