集合转字符串


调用接口时输入数据为List<>集合,可利用Joiner.on(",").join(ids);转化为字符串(以“,”分割)

 

 /*  依赖 <!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>28.0-jre</version>
    </dependency>*/
    @Test
    public void testJoiner(){
        List ids=new ArrayList<String>();
        ids.add("1");
        ids.add("2");
        String idStr = Joiner.on(",").join(ids);
        System.out.println(idStr);
    }

 

更多详解:https://blog.csdn.net/wwwdc1012/article/details/82228458


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM