• 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. }

     

  • 相关阅读:
    王道考研计算机网络——传输层
    Springboot框架中使用 Redis + Lua 脚本进行限流功能
    PyQt 定义控件SwitchButton 指南
    JAVA毕业设计河南口腔医疗机构线上服务系统计算机源码+lw文档+系统+调试部署+数据库
    智能指针 之 unique_ptr shared_ptr weak_ptr
    明远智睿IMX6Q烧写Ubuntu18系统,此方法同样适合其它系统!
    yml语法学习 SpringBoot配置文件自动装配 yml文件有提示读取配置文件
    【SQL性能优化】从数据页的角度理解B+树查询
    【人工智能】-- 搜索技术(状态空间法)
    【Leetcode】970. Powerful Integers
  • 原文地址:https://blog.csdn.net/weixin_61503139/article/details/127673131