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

后端 未结 3 802
孤街浪徒
孤街浪徒 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:20

    if Joiner is not a must you can use String.format()

    public static void main(String[] args) {
            List names = Arrays.asList("John", "Mary", "Henry");
            StringBuilder builder = new StringBuilder();
    
            for(int i=0; i

提交回复
热议问题