【发布时间】:2017-03-16 21:20:11
【问题描述】:
我有一个数组(id,name,salary)
我想使用员工搜索方法搜索特定的ID,我的代码是:
Employee SearchID(int i_d) {
for (int i = 0; i < staff.length; i++) {
boolean check = true;
if (staff[i].id == i_d) {
System.out.println("Id: " + staff[i].id + ", name: " + staff[i].name + " and salary: " + staff[i].salary);
} else {
System.out.println("Sorry, no record exists with record id = " + i_d);
}
}
return staff[i].id;
}
【问题讨论】:
-
那么,有什么问题?
-
我看不出是什么问题。
-
我有错误,无法完成
-
您是否有编译器错误或运行时错误?什么错误信息?
-
如果您有错误,那么您至少可以告诉我们错误是什么。