📜  string.join java 8 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:07.314000             🧑  作者: Mango

代码示例1
public class main {  
    public static void main(String args[]) {
        String[] wordsToJoin = new String[] {"Hi", "there", "<3"};
         // first argument is the delimeter
        String example1 = String.join(", ", wordsToJoin);
      
          // can also do this instead
        String example2 = String.join("^ ","Hi","there","<3");  
    
        System.out.println(example1; // Hi, there, <3
        System.out.println(example2); // Hi^there^<3
    }
}