Answers for "string.join java 8"

1

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
    }
}
Posted by: Guest on August-27-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language