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









Related Tutorials/Questions & Answers:
How to Convert ArrayList to Array?
How to convert Arraylist into String Array Java
Advertisements
How to Append Arrays in PHP
Convert List to ArrayList
Implementing ArrayList's functionalities into arrays - Java Beginners
Convert ArrayList To Array
How to create arrays in JavaScript?
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?
Convert ArrayList to Array
Convert Array to ArrayList
arraylist
Iterating java arrays
Converting java arrays into list
How to sort ArrayList in java
arrays
arrays
arrays
How to display nested ArrayList in JSF
arrays
How to create new arraylist using Java
arrays
Arrays
Comparing Arrays
ArrayList
Arrays
How to pass an arraylist from servlet to jsp?
java arrays
Arrays
arraylist
arraylist
how to search the string arraylist contains database rows?
How to Convert array to list in Java
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
arraylist of an arraylist
How to check if an arraylist contains a value in Java
arraylist
arraylist
How to convert into to String in Java?
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

Ads