-1
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]+", " );
}
}
使用該程序不出來puting任何迴應 如果statments我想會的工作最讓我知道如果有無法獲得數組給println
你可以,你只需要真正知道你在做什麼;)原則上我同意,但你不應該這樣做。 –
嗯,你可以......但是'String'變量只是指針,'=='只是檢查它們是否指向相同的內存地址,而不是兩個字符串的內容是否相等(不管他們在記憶中的位置)。 – nhgrif
謝謝你們幫我10倍 – Robbie