public ArrayList<Integer> FindNumbersWithSum(int [] array,int sum) {
ArrayList<ArrayList<Integer>> list = new ArrayList<>();
ArrayList<Integer> item = new ArrayList<Integer>();
for(int i=0;i<array.length;i++){
int temp = sum-array[i];
for(int j=i+1;j<array.length;j++){
if(temp==array[j]){
item.add(array[i]);//按照题目要求小的在前
item.add(array[j]);
list.add(new ArrayList<Integer>(item));
item.clear();
}
}
}
if(list.size()==0) return item;//此处不能返回null,而是返回空的item
//两个数的差值越大那么两个数的成绩就越小,返回第一组就是乘积最小的
return list.get(0);
}