How do i print the Characters inside an Arraylist without brackets [] showing? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

How do i print the Characters inside an Arraylist without brackets [] showing?

i thought .size might do it but its only showing the size of the array i tried y but this just shows the array list inside brackets maby i need .get()? but i dont know how to integrate it. ArrayList<Character> y = new ArrayList<Character>(); y.add((char)37); y.add((char)38); System.out.print(y.size());

10th Oct 2017, 2:15 PM
D_Stark
D_Stark - avatar
4 Answers
+ 9
Did you mean something like this? https://code.sololearn.com/cLQU2rsXqdFZ/?ref=app
10th Oct 2017, 3:05 PM
Shamima Yasmin
Shamima Yasmin - avatar
+ 7
Or you can use simple for loop as follows: for(int i=0; i<y.size(); i++){ System.out.println(y.get(i)); }
10th Oct 2017, 3:07 PM
Shamima Yasmin
Shamima Yasmin - avatar
+ 7
Other possibilities: ArrayList list // ... blabla initializing and stuff list.forEach(System.out::println); or list.stream().forEach(System.out::println);
10th Oct 2017, 6:08 PM
Tashi N
Tashi N - avatar
+ 5
thanks shamima works great
10th Oct 2017, 3:21 PM
D_Stark
D_Stark - avatar