I'm new to java so im having some "annoying" problems. I have a class Employee which contains an `int idNumber` and a `int phone number`. Then I have a `LinkedList` sorted by `idNumber`. I want to change the phonenumber of a certain `idnumber`.
I've been working with Iterators but i don't know if i'm doing it right, which I doubt.
public void setNewPhoneNumber(int idnumber, int newphone){
Iterator it = listEmployee.iterator();
IndexC employeeTemp = null;
boolean found = false;
while(it.hasNext() && !found){
employeeTemp = it.next();
if(employee.getIdNumber()== idnumber){
employeeTemp.setNewPhoneNumber(newphone);
found = true;
}
}
}
Yeah, I know `employee.setNewPhoneNumber` is wrong, but I don't know which the correct way change the value on the linkedlist. (Sorry for the bad english, not a native speaker)
Doesn´t that work? What error do you get? Why do you think it wouldn´t work?
以上就是Changing parameters in a LinkedList的详细内容,更多请关注web前端其它相关文章!