• StringJoiner可以嵌套使用的,简单使用常用于抛异常


    package com.gang;
    
    import java.util.Calendar;
    import java.util.Date;
    import java.util.HashSet;
    import java.util.StringJoiner;
    
    public class Harbor007 {
        public static void main(String[] args) {
           /* Calendar calendar = Calendar.getInstance();
    
            calendar.add(Calendar.SECOND,10);
            Date time = calendar.getTime();
            System.out.println(time);*/
    
          /*  HashSet set = new HashSet<>();
            set.add("1");
            set.add("1");
            set.add("1");
            System.out.println(set);*/
    
            StringJoiner notFourMustError = new StringJoiner(",");
            notFourMustError.add("刘备");
            notFourMustError.add("王道哈哈");
                StringJoiner result = new StringJoiner(",");
            System.out.println(notFourMustError);
    
            result.add(notFourMustError + "部分事项未审核,请审核后在结束会议");
    
            System.out.println(result.toString());
    
    
        }
    
    
        }
    
    
    if (notFourMustError.length() != 0 || allFailErrorMessage.length() != 0) {
        StringJoiner result = new StringJoiner(",");
    
        if (notFourMustError.length() != 0) {
            result.add(notFourMustError + "部分事项未审核,请审核后在结束会议");
        }
    
        if (allFailErrorMessage.length() != 0) {
            result.add(allFailErrorMessage + "影响任免,不允许结束会议");
        }
    
        throw new SystemAccountException(result.toString());
    }

    1. package com.gang;
    2. import java.util.Arrays;
    3. import java.util.List;
    4. import java.util.StringJoiner;
    5. import java.util.stream.Collectors;
    6. public class Test08 {
    7. public static void main(String[] args) {
    8. List list = Arrays.asList("大大", "的武当派开完票");
    9. System.out.println(list.stream().collect(Collectors.joining("$$$")));
    10. }
    11. }

     

  • 相关阅读:
    优雅迷人的小程序 UI 风格
    人机环境系统智能需要新的逻辑和数学体系
    2023 年 亚太赛 APMCM 国际大学生数学建模挑战赛 |数学建模完整代码+建模过程全解全析
    wx.canvasToTempFilePath导出的图片不清晰
    【云原生之kubernetes实战】部署k8s集群管理平台Wayne
    Linux内核定时器
    AVL双旋转思路分析与图解
    猿创征文|零基础python学习之旅(简短又漫长)
    《深入理解java虚拟机 第三版》学习笔记一
    【InternLM 笔记】使用InternLM2-chat-1.8b制作时事问答知识库
  • 原文地址:https://blog.csdn.net/weixin_61503139/article/details/127673131