Use like this.
List<String> stockList = new ArrayList<String>();
stockList.add("stock1");
stockList.add("stock2");
String[] stockArr = new String[stockList.size()];
stockArr = stockList.toArray(stockArr);
for(String s : stockArr)
System.out.println(s);
More Related Contents:
- How to check two array list are same content in same position
- Write a program that takes an array/arraylist of integer and finds longest sub array/arraylist whose entries are equal [closed]
- Android String that change every day
- Create ArrayList from array
- How can I avoid ArrayIndexOutOfBoundsException or IndexOutOfBoundsException? [duplicate]
- Converting ‘ArrayList to ‘String[]’ in Java
- Convert list to array in Java [duplicate]
- How to convert an ArrayList containing Integers to primitive int array?
- What is the diamond operator in Java? [duplicate]
- How can I create an Array of ArrayLists?
- Java: Detect duplicates in ArrayList?
- Variable length (Dynamic) Arrays in Java
- make arrayList.toArray() return more specific types
- Distinction between the capacity of an array list and the size of an array
- How do I declare a 2D String arraylist?
- Print ArrayList
- Using contains on an ArrayList with integer arrays
- Arrays.asList() of an array
- ArrayList: how does the size increase?
- casting Arrays.asList causing exception: java.util.Arrays$ArrayList cannot be cast to java.util.ArrayList
- Permutation algorithm for array of integers in Java
- Time Complexity for Java ArrayList
- How can I create an array in Kotlin like in Java by just providing a size?
- Converting an ArrayList into a 2D Array
- Java ArrayList how to add elements at the beginning
- Create an array of ArrayList elements
- Assigning an array to an ArrayList in Java
- Difference boolean[] b = {false} vs. boolean b = false? [closed]
- Populating a ListView using an ArrayList?
- How to convert a char array back to a string?