0

So, I have 2 methods that return each a list of the same type of my business layer object class.

I am trying to make a new method that creates a new ArrayList of also the same type and adds those 2 lists to it.

Would anyone know how to call these lists into that combined list? This don't seem to work.

public response getlist1() {
    ....

    return list1;
}

public response getlist2() {
    ....

    return list2;
}

public response getCombinedList() {
     ArrayList<...> = new ArrayList<...>();     
     combinedList.add(list1);                                                
     combinedList.add(list2);
     ...   
}
Tryliom
  • 101
  • 1
  • 17
John Doe
  • 11
  • 1

1 Answers1

4

In this case, I would go with addAll method of the list:

public response getCombinedList(){
     ArrayList<...> = new ArrayList<...>();     
     combinedList.addAll(list1);                                                
     combinedList.addAll(list2);    
}