Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Convert ArrayList to array in java
//Title of this code //'main' method must be in a class 'Rextester'. import java.util.*; import java.lang.*; import java.util.Arrays; import java.util.List; class Rextester { public static void main(String args[]) { List<String> list=new ArrayList<String>(); list.add("one"); list.add("two"); list.add("three"); String names[]=list.toArray(new String[list.size()]); for(int i=0;i<names.length;i++) System.out.println("Array :"+names[i]); String[] countries = {"India", "Switzerland", "Italy", "France"}; List<String> list1 = Arrays.asList(countries); System.out.println("ArrayList of Countries:" + list1); } }
run
|
edit
|
history
|
help
0
MergeSort
FizzBuzz
Counter.java
2
4.b
final method
calc exp ne
home by stars
JLF
Problem: on_off