How to Convert ArrayList to Array?

Ads
 

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
How to Append Arrays in PHP
Convert ArrayList To Array
Implementing ArrayList's functionalities into arrays - Java Beginners
How to create arrays in JavaScript?
How to concatenate two arrays in Java?
How to convert into to String in Java?
how to compare 2 arrays using java?
Converting java arrays into list
Iterating java arrays
How to convert NSString to NSInteger?
how to convert ACSII to HEX
How to Convert String to Date?
How to convert a String to an int?
How to convert String into java.util.Date
how to convert jsp to exe
How to display nested ArrayList in JSF
How to convert XML file to database ?
How to convert string to byte in Java
Comparing Arrays
How to create new arraylist using Java
how to convert sql into hql
How to pass an arraylist from servlet to jsp?
how to convert string to image in java
Convert ArrayList to Array
Convert Array to ArrayList
HOW TO CONVERT THIS CODE INTO GUI
How to sort ArrayList in java
arraylist

Ads