I need to print all arraylist values at a time using concat.
Here is my code:
ArrayList lst = new ArrayList();
lst.add(\"hi\"
Please prefer the List
interface to the ArrayList
concrete type. Assuming you are using Java 8+, you might use a Stream
and Collectors.joining
(and Arrays.asList
) like
List lst = Arrays.asList("hi", "hello");
String r = lst.stream().collect(Collectors.joining(" "));
System.out.println(r);
Which outputs
hi hello
As requested.