I want the user to enter 3 names and the program will make 6 combinations of it. After, ask the user again to select a name by entering a number based on the combination of names. For example the user inputs: name1, name2 and name3. The combinations would be: name1 name2, name1 name 3, name2 name 1, name2 name3, name3 name1, name3 name2. And the user will pick from those combinations by entering a number associated with the combinations. I've tried doing it but can't really get on how to make the combinations.
import java.util.Scanner;
public class Strings1 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Please enter 3 names: ");
String name1 = input.nextLine();
String name2 = input.nextLine();
String name3 = input.nextLine();
String names[] = {name1, name2, name3};
System.out.println("Possible combinations are: ");
for (int i = 1; i <= 6; i++) {
System.out.println(i + " - " + names[0] + " " + names[1]);
}
}
}