Preferred Idiom for Joining a Collection of Strings in Java

后端 未结 7 1643
悲哀的现实
悲哀的现实 2020-11-30 11:20

Given a Collection of Strings, how would you join them in plain Java, without using an external Library?

Given these variables:

Collection

        
7条回答
  •  时光说笑
    2020-11-30 11:52

    Different intentions:

    For third-part tools, such as Guava's Joiner, which is not fast, but very flexible. There are many option methods to customize join behavior, such as skipNulls().

    Plain Java is fast, but it needs you write some lines of codes by yourself.

提交回复
热议问题