我一直在为链接列表项目编写构造函数时遇到问题,并且似乎无法弄清楚为什么 charAt 在这种情况下不起作用。我收到一个错误:在调用 charAt 时找不到符号。
//copy
public Project123(Project123 s){
this.head = null;
for (int i = s.length()-1; i>=0; i--){
head = new charNode (s.charAt(i), head);
}
}
//constructor
public Project123(String s){
this.head = null;
for (int i = s.length()-1; i>=0; i--){
head = new charNode (s.charAt(i), head);
}
}
我似乎没有与其他相关帖子相同的问题。它是小写的,似乎也被正确调用了。如果需要更多上下文,我会发布更多。