Java 8 has added a static join method to the String class. This concatenates Strings using a delimiter. Performance wise, it is similar to StringBuffer.append, but it has the added advantage that it automatically adds a delimiter.
As before, this code creates string1 and string2. It invokes the join method with these Strings and specifies space (“ “) as a delimiter. So, this code prints the following output:red blue