How to get different grouping combinations from a list
问题 I'm working on a problem where I want to group a list by two's and get all possible combinations. for example: for the list [A,B,C,D]; I'm trying to create a method that will give me the ff: A and BCD B and ACD C and ABD D and ABC AB and CD AC and BD AD and BC etc... I know that recursion is the answer but I don't know where to start. Can someone point me to the right direction? My attempt so far: List<String> list = new ArrayList<>(); list.add("A"); list.add("B"); list.add("C"); list.add("D"