Dave's Brain

Browse - Programming Tips - How can I concatenate two ArrayLists?

Date: 2012nov2
Language: java
Keywords: add, attach, join

Q.  How can I concatenate two ArrayLists?

A.  Here's a method that does that:

ArrayList<String> concat(ArrayList<String> a, ArrayList<String> b) { ArrayList<String> out = new ArrayList<String>(); out.addAll(a); out.addAll(b); return out; }

Add a comment

Sign in to add a comment
Copyright © 2008-2018, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.