Is there a way to join strings, each with a specific surrounding string?

后端 未结 3 831
孤街浪徒
孤街浪徒 2021-01-13 13:35

I\'m looking to use guava\'s Joiner to join List into one string, but with surrounding strings around each one in the list. So I want

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-13 14:17

    The way to do this is with a transform, first:

     Joiner.on(", ").join(Iterables.transform(names, new Function() {
       public String apply(String str) { return "your guest " + str + " is here"; }
     }));
    

提交回复
热议问题