The join() method of Longs Class in the Guava library is used to combine or join all the given long values separated by a separator. These long values are passed a parameter to this method. This method also takes the separator as the parameter. This method returns a String which is the result of join operation on the specified long values.
For example: join(“-“, 1L, 2L, 3L) returns the string “1-2-3”.
public static String join(String separator, long… array)
Parameters: This method accepts two mandatory parameters:
- separator: which is the character that occurs in between the joined long values.
- array: which is an array of long values that are to be joined.
Return Value: This method returns a string containing all the given long values separated by separator.
Below programs illustrate the use of this method:
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.