//我的问题是,在方法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'单个'字符串变量'这是不可能的..更好的方法是比较一个接一个元素'字符串变量' –