//我的問題是,在方法cancelOrder中字符串[] waitingList []至少沒有被看到,這是我的想法。比較ArrayList到字符串
public static String[] canceledOrder(String[] waitingList,String[] waitingList1,String []waitingList2,String[] waitingList3){//I've decided to pass these string [] hoping the string from the other methods will now be seen in canceledOrder();
Scanner in = new Scanner (System.in);
int option;
System.out.println("Select the event you want to cancel :\n");
events();
option= in.nextInt();
in.nextLine();
System.out.println("Person on wait list is " + waitingList[name]);
switch (option){
case 1:
System.out.println("Please enter your name:\n");
canceledname = in.nextLine();
System.out.println("name:" + canceledname);
for (String s : myStringList) {
if(s.equals(canceledname)){
s = waitingList[name];
System.out.println("The new name is\n" + s);
name++;
}
return s; // I want it to now return waitingList[name]
}
break;
你說的比較是什麼意思?當然,'ArrayList'不能等於'String'嗎? –
你的意思是檢查ArrayList是否包含字符串? – allejo
我想你想比較'myStringList'裏面的元素,對不對?或者如果你想比較整個'myStringList'單個'字符串變量'這是不可能的..更好的方法是比較一個接一個元素'字符串變量' –