How can i return 2 ArrayList From same method

Well if you really have to, you could wrap them up into an object, that just has 2 List fields.

Alternativly you could return a Map of the 2 Lists, with an unique key for each.


It is not possible two return statement from single function but you can wrap in new Map or List and can return two ArrayList.

public Map<String,List<EmailUID>> getList()
  List<EmailUID> emailList = new ArrayList<EmailUID>();
  List<EmailUID> eventList = new ArrayList<EmailUID>();
  ...
  Map<String,List<EmailUID>> map =new HashMap();
  map.put("emailList",emailList);
  map.put("eventList",eventList);
  return map;
}

Tags:

Java

Arraylist