Java Guava | Longs.asList() method with Examples Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 list returned by the method and vice-versa. Syntax: public static List<Long> asList(long... backingArray) Parameter: The method accepts a mandatory parameter backingArray which is a long array that is used to back the list. Return Value: The method Longs.asList() returns a fixed-size list which is backed by the array passed as the argument to the method. In other words, the method returns the list view of the array. Below examples illustrate the implementation of above method: Example 1: Java // Java code to show implementation of // Guava's Longs.asList() method import com.google.common.primitives.Longs; import java.util.List; class GFG { // Driver's code public static void main(String[] args) { // Creating a Long array long arr[] = { 1, 2, 3, 4, 5 }; // Using Longs.asList() method to wrap // the specified primitive Long array // as a List of the Long type List<Long> myList = Longs.asList(arr); // Displaying the elements in List System.out.println(myList); } } Output: [1, 2, 3, 4, 5] Example 2: Java // Java code to show implementation of // Guava's Longs.asList() method import com.google.common.primitives.Longs; import java.util.List; class GFG { // Driver's code public static void main(String[] args) { // Creating a Long array long arr[] = { 3, 5, 7 }; // Using Longs.asList() method to wrap // the specified primitive Long array // as a List of the Long type List<Long> myList = Longs.asList(arr); // Displaying the elements in List System.out.println(myList); } } Output: [3, 5, 7] Reference: https://guava.dev/releases/21.0/api/docs/com/google/common/primitives/Longs.html#asList-long...- 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.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.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.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.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 | Chars.asList() method with Examples The Chars.asList() method of Guava's Chars Class accepts a char array as a parameter and returns a list which has the fixed size. The returned list is backed by the char 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 | Chars.asList() method with Examples The Chars.asList() method of Guava's Chars Class accepts a char array as a parameter and returns a list which has the fixed size. The returned list is backed by the char 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 Like