Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

string.join java 8

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
    }
}
 
PREVIOUS NEXT
Tagged: #java
ADD COMMENT
Topic
Name
4+3 =