+ 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());
4 Respostas
+ 9
Did you mean something like this?
https://code.sololearn.com/cLQU2rsXqdFZ/?ref=app
+ 7
Or you can use simple for loop as follows:
for(int i=0; i<y.size(); i++){
System.out.println(y.get(i));
}
+ 7
Other possibilities:
ArrayList list // ... blabla initializing and stuff
list.forEach(System.out::println);
or
list.stream().forEach(System.out::println);
+ 5
thanks shamima works great