Changing parameters in a LinkedList

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前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏