Java判断两个集合内容是否相同

实体类

@Data
public class SmPersonSinceGrandOpen {
    /** 跑批日期 */
    private String workdateSm;
    /** 统计维度(年龄段/家庭) 0:年龄段,1:家庭非家庭 */
    private String dimStatsSm;
    /** 维度详情 18岁以下/18-25岁/26-35岁/36-45/46-50岁/51岁及以上/家庭/非家庭 */
    private String dimDetailSm;
    /** 人数 */
    private String personNumSm;
    /** 占比 */
    private String percentSm;
}

比较代码

        List<SmPersonSinceGrandOpen> sms = new ArrayList<SmPersonSinceGrandOpen>(){{
            SmPersonSinceGrandOpen sm1 = new SmPersonSinceGrandOpen();
            sm1.setWorkdateSm("1");
            sm1.setDimStatsSm("1");
            sm1.setDimDetailSm("1");
            sm1.setPersonNumSm("1");
            sm1.setPercentSm("1");
            add(sm1);
            SmPersonSinceGrandOpen sm2 = new SmPersonSinceGrandOpen();
            sm2.setWorkdateSm("2");
            sm2.setDimStatsSm("2");
            sm2.setDimDetailSm("2");
            sm2.setPersonNumSm("2");
            sm2.setPercentSm("2");
            add(sm2);
        }};

        List<SmPersonSinceGrandOpen> sms1 = new ArrayList<SmPersonSinceGrandOpen>(){{
            SmPersonSinceGrandOpen sm1 = new SmPersonSinceGrandOpen();
            sm1.setWorkdateSm("1");
            sm1.setDimStatsSm("1");
            sm1.setDimDetailSm("1");
            sm1.setPersonNumSm("1");
            sm1.setPercentSm("1");
            add(sm1);

            SmPersonSinceGrandOpen sm2 = new SmPersonSinceGrandOpen();
            sm2.setWorkdateSm("2");
            sm2.setDimStatsSm("2");
            sm2.setDimDetailSm("2");
            sm2.setPersonNumSm("2");
            sm2.setPercentSm("2");
            add(sm2);
/*            SmPersonSinceGrandOpen sm3 = new SmPersonSinceGrandOpen();
            sm3.setWorkdateSm("3");
            sm3.setDimStatsSm("3");
            sm3.setDimDetailSm("3");
            sm3.setPersonNumSm("3");
            sm3.setPercentSm("3");
            add(sm3);*/

        }};

        sms.sort(Comparator.comparingLong(SmPersonSinceGrandOpen::hashCode));
        sms1.sort(Comparator.comparingLong(SmPersonSinceGrandOpen::hashCode));

        System.out.println(sms.toString().equals(sms1.toString()));
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇