我在Java讓利的方法時返回多個對象說:如何傳遞兩個數組參數
public List<Data> getData(String[] str, Integer[] num, String ss);
我要傳遞兩個數組和非數組參數如上圖所示,此方法返回的列表Data類型的對象。
現在,問題是如何創建一個包含數組元素的每種可能組合的對象列表。
即:對象的元素:
getData(String[0] str, Integer[0] num, String ss);
getData(String[0] str, Integer[1] num, String ss);
getData(String[1] str, Integer[0] num, String ss);
getData(String[1] str, Integer[1] num, String ss);
任何線索將不勝感激。
使用嵌套循環。對不起,我不會寫你的代碼,因爲這看起來非常像作業,你應該做你的研究。如果你問什麼是嵌套循環,那麼我們很樂意提供幫助 – gerrytan