- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Ints asList() function in Java
The asList() method of the Ints class in Java Guava’s returns a fixed-size list backed by the specified array. The syntax is as follows −
public static List<Integer> asList(int[] arr)
Here, arr is the array to back the list.
Let us see an example to implement the asList() method of the Ints class −
Example
import com.google.common.primitives.Ints; import java.util.List; class Demo { public static void main(String[] args) { int arr[] = { 20, 30, 40, 60, 80, 90, 120, 150 }; System.out.println("Array elements = "); for(int i = 0; i < arr.length; i++) { System.out.println(arr[i]); } List<Integer> list = Ints.asList(arr); System.out.println("List = "+ list); } }
Output
Array = 20 30 40 60 80 90 120 150 List = [20, 30, 40, 60, 80, 90, 120, 150]
- Related Articles
- Ints concat() function in Java
- Ints contains() function in Java
- Ints indexOf() function in Java
- Ints join() function in Java
- Ints lastIndexOf() function in Java
- Ints max() function in Java
- Ints toArray() function in Java
- Ints Class in Java
- Importance of deepToString() and asList() methods in Java?
- Java Program to divide a number into smaller random ints
- How to sort a slice of ints in Golang?
- Function pointers in Java
- Function interface in Java
- How to know Maximum and Minimum values for ints in Python?
- Searching an element of int type in slice of ints in Golang

Advertisements