Share on Google+Share on Google+

Convert Array to List

In this section, you will learn to convert an Array to List.

Convert Array to List


In this section, you will learn to convert an Array to List. 

Code Description:

This program helps you in converting an Array to List. Here we have taken an array of data which gets converted to List using Array.asList mathod. We have also used collection.sort method to get the data in sorted order.

import java.util.Arrays;
import java.util.Collections;
import java.util.*;

public class ArrToList {
  public static void main(String args[]) {
  String[] strArray = new String[] {"Piano""Guitar",

  List l = Arrays.asList(strArray);

Output of the program: 


C:\unique>java ArrToList
[Drums, Flute, Guitar, Piano, Violen]


Download this example.



Posted on: August 6, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Discuss: Convert Array to List   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image