【发布时间】:2013-11-08 00:37:29
【问题描述】:
我在为链接列表项目编写构造函数时遇到了问题,并且似乎无法弄清楚为什么 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);
}
}
我似乎没有与其他相关帖子相同的问题。它是小写的,似乎也被正确调用了。如果需要更多上下文,我会发布更多。
【问题讨论】:
-
请不要将你的班级命名为
Object。 -
它实际上不在项目中。为了理智,我会改变。
标签: java string linked-list char copy-constructor