我有問題從這個方法返回ArrayList。該方法應該檢查給定的保險類型與存儲的保險類型。如果匹配,那麼該元素將被刪除,其餘的將被顯示。從方法返回ArrayList
請建議的語法,這裏返回數組列表
public ArrayList<Insurance> retrieveDetails(String insType){
Iterator<Insurance> itr=insurancelist.iterator();
while(itr.hasNext()) {
Insurance c=itr.next();
if(c.getInsuranceType().equals(insType)) {
insurancelist.remove(c);
}
else
System.out.println(c);
}
這甚至不會編譯 - 你有不平衡{} – NickJ
你應該添加return語句 – Abdelhak
u能請建議用於返回數組列表的語法 – Jason