Java Guava | Longs.join() method with Examples Last Updated : 31 Jan, 2019 Comments Improve Suggest changes Like Article Like Report 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". Syntax: 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: Example 1: Java // Java code to show implementation of // Guava's Longs.join() method import com.google.common.primitives.Longs; import java.util.Arrays; class GFG { // Driver's code public static void main(String[] args) { // Creating a long array long[] arr = { 2, 4, 6, 8, 10 }; // Using Longs.join() method to get a // string containing the elements of array // separated by a separator System.out.println(Longs.join("#", arr)); } } Output: 2#4#6#8#10 Example 2: Java // Java code to show implementation of // Guava's Longs.join() method import com.google.common.primitives.Longs; import java.util.Arrays; class GFG { // Driver's code public static void main(String[] args) { // Creating a long array long[] arr = { 3, 5, 7, 9, 11 }; // Using Longs.join() method to get a // string containing the elements of array // separated by a separator System.out.println(Longs.join("*", arr)); } } Output: 3*5*7*9*11 Reference: https://google.github.io/guava/releases/21.0/api/docs/com/google/common/primitives/Longs.html#join-java.lang.String-long...- Comment More infoAdvertise with us Next Article Java Guava | Longs.join() method with Examples S Sahil_Bansall Follow Improve Article Tags : Java java-guava Guava-Functions Guava-Longs Practice Tags : Java Similar Reads Java Guava | Longs.concat() method with Examples The concat() method of Longs Class in the Guava library is used to concatenate the values of many arrays into a single array. These long arrays to be concatenated are specified as parameters to this method. For example: concat(new long[] {1, 2}, new long[] {3, 4, 5}, new long[] {6, 7} returns the ar 3 min read Java Guava | Longs.asList() method with Examples The Longs.asList() method of Guava's Longs Class accepts a long array as a parameter and returns a list which has the fixed size. The returned list is backed by the long array which is passed as the argument. It means the changes made in the array passed as parameter will be reflected back in the li 2 min read Java Guava | Longs.compare() method with Examples Longs.compare() method of Guava's Longs Class is used to compare the two specified long values. These values are passed as the parameter and the result of comparison is found as the difference of 1st value and the 2nd value. Hence it can be positive, zero or negative. Syntax: public static int compa 2 min read Java Guava | Longs.hashCode() method with Examples Longs.hashCode() is a method of Longs Class in Guava Library which is used to return a hash code for a long value. The hashCode is an unique integer value that is calculated by the compiler for an object. It remain the same if the object value does not changes. Syntax: public static int hashCode(lon 2 min read LongAdder longValue() method in Java with Examples LongAdder class in Java creates a new adder with an initial sum of zero. The Java.LongAdder.longValue() is an inbuilt method in java that returns the sum(). This method is equivalent to the sum() method. When the object of the class is created its initial value is zero. Syntax: public long longValue 2 min read Like