-2
我需要将“用户”添加到链接列表中,并且链接列表是链接列表的一部分。添加链接列表java
public void shibutz(user a){
this.serverList(this.placeInServerList(a.code)).add(a);
服务器列表是链接列表的链接列表。 这些都是该行使用的类:
public int placeInServerList(String code){
if (this.serverList.contains(code)){
return indentifyCode(code);
}
return -42;
}
public int indentifyCode (String code){
int counter=0;
Group i= this.serverList.getFirst();
while (this.serverList!=null){
if (i.getCode()==code){
return counter; }
counter++;
i=this.serverList.get(counter);
return indentifyCode (code);
}
return -42;}
组是一个链表。 现在,我需要第一个代码部分的帮助。我不明白Eclipse希望从我那里得到什么。它给我的解决方案都不是相对的。谢谢!!!
什么问题......?代码的作用与你想要做什么? –
您需要使用'equals'才能正确比较字符串。这行代码'if(i.getCode()== code){'应该替换为'i.getCode()。equals(code)'因为'code'是一个'String' public int indentifyCode(String code )' –