# Combining several collections into one

Is there a way to rewrite this code to make it more laconic? I'm using Java 6.

Object value = methodOutOfMyControl();
Set<String> strings = new HashSet<String>();
for (LinkedHashSet<String> set : values) {
}


I feel that sometimes inlining some values makes things a little more readable. But in terms of overall compactness, this isn't that much better. Here is what I would probably write

Map value = (Map)methodOutOfMyControl();
Set<String> strings = new HashSet<String>();
for (Map.Entry<Object, LinkedHashSet<String>> set : value.entrySet()) {

• If possible, supply the instantiation of the set with an educated guess of the number of elements to support. Map.entrySet() may be costly, and I don't see it used to advantage (avoid lookups) here. – greybeard Feb 11 '16 at 8:29
    int MEMBERS_TO_EXPECT = 12345;