I have 4 separate hashmaps all of the same type. I would like to merge the values of them all into a single list. I know how to set a List to hashMapOne.values(), but this doesn't help me here since I need to add all values from all 4 lists. Can I do this without looping and individually adding each one?
HashMap<String, MyEntity> hashMapOne = new HashMap<String, MyEntity>();
HashMap<String, MyEntity> hashMapTwo = new HashMap<String, MyEntity>();
HashMap<String, MyEntity> hashMapThree = new HashMap<String, MyEntity>();
HashMap<String, MyEntity> hashMapFour = new HashMap<String, MyEntity>();
List<MyEntity> finalList = new ArrayList<MyEntity>();
MyEntityside of all the HashMaps, considerArrayList.AddAll()docs.oracle.com/javase/8/docs/api/java/util/…new arraylist(h1).addall(h2).addAll(h3)etc.? If so: that's part of the standard ArrayList API. Give its method list a read-over, it's worth knowing what it supports out of the box.