How to Convert ArrayList to Array?

How to Convert ArrayList to Array?

Hi,

I am trying to learn to Convert ArrayList to Array.

How it is possible?

How to Convert ArrayList to Array?

Thanks

View Answers

April 17, 2017 at 8:47 AM

Hi,

To Convert ArrayList to array ArrayList.toArray() method can be used.

    List<String> names= new ArrayList<String>();
    names.add("Deepak");
    names.add("Rajeev");
    String [] namesList= names.toArray(new String[names.size()]);

So, above code is an example of converting ArrayList to Array.

Check more examples at Convert ArrayList to Array.

Thanks

Ads









Related Tutorials/Questions & Answers:
How to Convert ArrayList to Array?
How to convert Arraylist into String Array Java
Advertisements
Convert List to ArrayList
Convert ArrayList To Array
How to concatenate two arrays in Java?
swap two integer arrays
swap two integer arrays
swap two integer arrays
how to compare 2 arrays using java?
arraylist
Convert ArrayList to Array
Convert Array to ArrayList
How to sort ArrayList in java
How to create new arraylist using Java
How to pass an arraylist from servlet to jsp?
ArrayList
arrays
arrays
arrays
arrays
arrays
how to search the string arraylist contains database rows?
arraylist
Comparing Arrays
arraylist
Arrays
arraylist of an arraylist
How to find maximum value in ArrayList
How to find maximum value in ArrayList
How to find maximum value in ArrayList
How to find maximum value in ArrayList

Ads