我有问题。我想检查我的指定索引的 ararylist 索引是否为空。用户可能在我的数组列表中输入了 7 个项目(索引 0 到 6)。所以我想检查索引 7 是否为空,如果为空,我将循环回我的 RoomSelection()。
我正在使用 roomInfo(4+ xx)IsEmpty。
IsEmpty 命令是否用于检查整个数组列表是否为空?
如果要检查整个 arraylist ,我可以使用什么其他方法来检查索引 7 是否为空?
for (int x = 0; x < (Integer) roomInfo.get(2); x++) {//start of number of room loop(to check how many rooms user input)
for (int i = 0; i < (Integer) roomInfo.get(4 + xx); i++) { //start of number of add-on loop(to check how many add-on user input)
System.out.println("addOns array contains what? : " + addOns); // for my own reference
System.out.println("Enter Add-On option");
ao2 = input.nextInt();
while (ao2 > 4) {
System.out.println("Please enter again! Choose only option 1 to 4");
ao2 = input.nextInt();
}
addOnOpt = addOn[ao2 - 1];
addOns.add(addOnOpt);
addOnPrice = priceAdd[ao2 - 1];
addOns.add(addOnPrice);
System.out.println("Enter quantity required for Add-On option " + (i + 1) + ": ");
quan = input.nextInt();
addOns.add(quan);
xx += 3;
System.out.println(" not null yet");
if ((roomInfo.isEmpty(4 + xx) == true) {//if condition to check whether is the arrayllist of position is not null
System.out.println("null!");
xx = 0;
Selection();
}
}// end of add-on loop
}//end of number of room loop