String name;
String count;
Scanner keyboardn = new Scanner(System.in);
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter Full Product Name");
name = keyboard.nextLine();
count = keyboard.nextLine();
String [] p = name.split(" ");
for(String s : p) {
if (count == "1"){ System.out.println(p[0]);}
if (count == "2"){ System.out.println(p[1]);}
if (count == "3"){System.out.println(p[1]);}
if (count == "4"){System.out.println(p[1]);}
if (count == "5"){System.out.println(p[1]);}
if (count == "6"){System.out.println(p[1]);}
if (count == "7"){System.out.println(p[1]);}
if (count == "8"){System.out.println(p[1]);}
if (count == "9"){System.out.println(p[1]);}
if (count == "10"){System.out.println(p[0]+", "+p[1]+", "+ p[2]+", "+p[3]+", "+p[4]+", "+p[5]+", "+p[6]+", "+p[7]+", "+p[8]+", "
+ ""+p[9]+", "+p[1]+p[2]+", "+p[1]+p[2]+p[4]+", "+p[1]+p[2]+p[4]+p[5]+", " );
}
}
プログラムは if ステートメントを使用して応答を出力していません。他の提案があれば教えてください。