java Integer listSize is read from input, then listSize strings are read from input and stored in ArrayList namesToPick. The recursive method listNames() explores all possible arrangements of two names picked from namesToPick. In listNames(), write the base case to output the following items if the size of ArrayList pickedNames is 2:
"1st: "
first element in pickedNames
", 2nd: "
second element in pickedNames
End with a newline.
Click here for example
Ex: If the input is:
3
Bob Huy Kim
then the output is:
All possible arrangements:
1st: Bob, 2nd: Huy
1st: Bob, 2nd: Kim
1st: Huy, 2nd: Bob
1st: Huy, 2nd: Kim
1st: Kim, 2nd: Bob
1st: Kim, 2nd: Huy