Java Guava | Longs.concat() method with Examples Last Updated : 31 Jan, 2019 Comments Improve Suggest changes Like Article Like Report 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 array {1, 2, 3, 4, 5, 6, 7}. Syntax: public static long[] concat(long[]... arrays) Parameter: This method accepts arrays as parameter which is the long arrays to be concatenated by this method. Return Value: This method returns a single long array which contains all the specified long array values in its original order. Below programs illustrate the use of concat() method: Example 1: Java // Java code to show implementation of // Guava's Longs.concat() method import com.google.common.primitives.Longs; import java.util.Arrays; class GFG { // Driver's code public static void main(String[] args) { // Creating 2 Long arrays long[] arr1 = { 1, 2, 3, 4, 5 }; long[] arr2 = { 6, 2, 7, 0, 8 }; System.out.println("Long Array 1: " + Arrays.toString(arr1)); System.out.println("Long Array 2: " + Arrays.toString(arr2)); // Using Longs.concat() method to combine // elements from both arrays // into a single array long[] res = Longs.concat(arr1, arr2); // Displaying the single combined array System.out.println("Combined Array: " + Arrays.toString(res)); } } Output: Long Array 1: [1, 2, 3, 4, 5] Long Array 2: [6, 2, 7, 0, 8] Combined Array: [1, 2, 3, 4, 5, 6, 2, 7, 0, 8] Example 2: Java // Java code to show implementation of // Guava's Longs.concat() method import com.google.common.primitives.Longs; import java.util.Arrays; class GFG { // Driver's code public static void main(String[] args) { // Creating 4 long arrays long[] arr1 = { 1, 2, 3 }; long[] arr2 = { 4, 5 }; long[] arr3 = { 6, 7, 8 }; long[] arr4 = { 9, 0 }; System.out.println("Long Array 1: " + Arrays.toString(arr1)); System.out.println("Long Array 2: " + Arrays.toString(arr2)); System.out.println("Long Array 3: " + Arrays.toString(arr3)); System.out.println("Long Array 4: " + Arrays.toString(arr4)); // Using Longs.concat() method to combine // elements from both arrays // into a single array long[] res = Longs .concat(arr1, arr2, arr3, arr4); // Displaying the single combined array System.out.println("Combined Array: " + Arrays.toString(res)); } } Output: Long Array 1: [1, 2, 3] Long Array 2: [4, 5] Long Array 3: [6, 7, 8] Long Array 4: [9, 0] Combined Array: [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] Reference: https://google.github.io/guava/releases/21.0/api/docs/com/google/common/primitives/Longs.html#concat-long:A...- Comment More infoAdvertise with us Next Article Java Guava | Longs.concat() 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.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.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.join() method with Examples 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 joi 2 min read Java Guava | Shorts.concat() method with Examples Shorts.concat() is a method of Shorts class in Guava library which is used to concatenate the values of multiple arrays into a single array. For example, concat(new short[] {a, b}, new short[] {}, new short[] {c} returns the array {a, b, c}. Syntax : public static short[] concat(short[]... arrays) H 2 min read Java Guava | Booleans.concat() method with Examples The concat() method of Booleans Class in the Guava library is used to concatenate the values of many arrays into a single array. These boolean arrays to be concatenated are specified as parameters to this method. For example: concat(new boolean[] {a, b}, new boolean[] {}, new boolean[] {c} returns t 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 Java String concat() Method with Examples The string concat() method concatenates (appends) a string to the end of another string. It returns the combined string. It is used for string concatenation in Java. It returns NullPointerException if any one of the strings is Null.In this article, we will learn how to concatenate two strings in Jav 4 min read Java Guava | Shorts.asList() method with Examples The Shorts.asList() method of Guava's Shorts Class accepts a short array as a parameter and returns a list which has the fixed size. The returned list is backed by the short array which is passed as the argument. It means the changes made in the array passed as parameter will be reflected back in th 2 min read Byte longValue() method in Java with examples The longValue() method of Byte class is a built in method in Java which is used to return the value of this Byte object as long. Syntax ByteObject.longValue() Return Value: It return the value of ByteObject as long. Below is the implementation of longValue() method in Java: Example 1: Java // Java c 2 min read CompoundName add() method in Java with Examples The add() method of a javax.naming.CompoundName class is used to add the component to the CompoundName object. There are two different add method. add(int, String): This method is used to add a single component at a specified position posn passed as a parameter within this compound name. The other c 4 min read Like