I have a List of elements (1, 2, 3), and I need to get the superset (powerset) of that list (without repeating elements). So basically I need to create a List of Lists that
This is the simple function can be used to create a list of all the possible numbers generated by digits of all possible subsets of the given array or list.
void SubsetNumbers(int[] arr){
int len=arr.length;
List list=new ArrayList();
List list1=new ArrayList();
for(int n:arr){
if(list.size()!=0){
for(int a:list){
list1.add(a*10+n);
}
list1.add(n);
list.addAll(list1);
list1.clear();
}else{
list.add(n);
}
}
System.out.println(list.toString());
}