How to return multiple objects from a Java method?

前端 未结 25 3075
眼角桃花
眼角桃花 2020-11-21 23:55

I want to return two objects from a Java method and was wondering what could be a good way of doing so?

The possible ways I can think of are: return a HashMap<

25条回答
  •  既然无缘
    2020-11-22 00:27

    While in your case, the comment may be a good way to go, in Android, you can use Pair . Simply

    return new Pair<>(yourList, yourCommaSeparatedValues);
    

提交回复
热议问题