- 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
How to switch data from an array to array list in java?
The Arrays class of the java.util package provides you a method named asList(). This method accepts an array (of objects) and converts them into a list and returns it.
Example
import java.util.Arrays; import java.util.List; public class ArrayToList { public static void main(String args[]) { Integer[] myArray = {23, 93, 56, 92, 39}; List list = Arrays.asList(myArray); System.out.println(list); } }
Output
[23, 93, 56, 92, 39]
Advertisements