What am i doing wrong?


#1

public class Solution {
public void explore(ArrayList A,ArrayList temp,ArrayList<ArrayList> result,int index)
{
if(index == A.size())
{
result.add(temp);
return;
}
temp.add(A.get(index));
explore(A,temp,result,index+1);

    temp.remove(temp.size()-1);
    explore(A,temp,result,index+1);
}
public ArrayList<ArrayList<Integer>> subsets(ArrayList<Integer> A) {
    ArrayList<ArrayList<Integer>> result = new ArrayList();
    Collections.sort(A);
    ArrayList<Integer> temp = new ArrayList();
    explore(A,temp,result,0);
    
    return result;
}

}

Final output is arraylist of empty arraylists.