How to Convert ArrayList to Array?

 
 

Share on Google+Share on Google+

Java Coder
How to Convert ArrayList to Array?
1 Answer(s)      8 months ago
Posted in : Java Beginners
Ads

Hi,

I am trying to learn to Convert ArrayList to Array.

How it is possible?

How to Convert ArrayList to Array?

Thanks

Ads
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









Ads

 
Advertisement null

Ads