The following code converts ArrayList<String>
to char[]
and print output which appears as [back, pack]
. Here, the char[]
includes ','
and ' '
. Is there a way to do it in another way to get rid of comma and space?
ArrayList<String> list = new ArrayList<String>();
list.add("back");
list.add("pack");
char[] chars = list.toString().toCharArray();
for (char i : chars){
System.out.print(i);
}