Ints asList() function | Guava | Java
Guava’s Ints.asList() returns a fixed-size list backed by the specified array.
Syntax:
public static List<Integer>
asList(int[] array)
Parameters: This method takes the array as parameter which is the array to back the list.
Return Value: This method returns a fixed-size list backed by the specified array.
Example 1:
// Java code to show implementation of // Guava's Ints.asList() method import com.google.common.primitives.Ints; import java.util.List; class GFG { // Driver's code public static void main(String[] args) { // Creating an integer array int arr[] = { 1, 2, 3, 4, 5 }; // Using Ints.asList() method to wrap // the specified primitive Integer array // as a List of the Integer type List<Integer> myList = Ints.asList(arr); // Displaying the elements in List System.out.println("List of given array: " + myList); } } |
chevron_right
filter_none
Output:
List of given array: [1, 2, 3, 4, 5]
Example 2:
// Java code to show implementation of // Guava's Ints.asList() method import com.google.common.primitives.Ints; import java.util.List; class GFG { // Driver's code public static void main(String[] args) { // Creating an integer array int arr[] = { 3, 5, 7 }; // Using Ints.asList() method to wrap // the specified primitive Integer array // as a List of the Integer type List<Integer> myList = Ints.asList(arr); // Displaying the elements in List System.out.println("List of given array: " + myList); } } |
chevron_right
filter_none
Output:
List of given array: [3, 5, 7]
Recommended Posts:
- Ints contains() function | Guava | Java
- Ints max() function | Guava | Java
- Ints min() function | Guava | Java
- Ints join() function | Guava | Java
- Ints toArray() function | Guava | Java
- Ints concat() function | Guava | Java
- Ints lastIndexOf() function | Guava | Java
- Ints indexOf() function | Guava | Java
- Java Guava | Shorts.asList() method with Examples
- Java Guava | Longs.asList() method with Examples
- Java Guava | Chars.asList() method with Examples
- Java Guava | Floats.asList() method with Examples
- Java Guava | Bytes.asList() method with Examples
- Java Guava | Doubles.asList() method with Examples
- Java Guava | Booleans.asList() method with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


