ArrayList to array Java
Ngày đăng:
30/11/2021
Trả lời:
0
Lượt xem:
34
In this post we have shared two methods of converting an ArrayList Show Method 1: Manual way of conversion using ArrayList get() methodThis is a manual way of copying all theArrayList Method2: Conversion using toArray() methodIn the above example we have manually copied each element of the array list to the array. However there is a methodtoArray() which can convert the ArrayList of string type to the array of Strings. More about toArray() here. package beginnersbook.com; import java.util.*; public class Example { public static void main(String[] args) { /*ArrayList declaration and initialization*/ ArrayListOutput: Ankur Ajeet Harsh John |