关于Java中链表的问题
Cat------>Dog------>Horse----->Parrot
^P1 ^P2 ^P3 ^P4
执行以下语句后绘制生成的链表:
P4 = P2;
P3.info = P2.info
等等。
我的问题是,“.info”引用什么?
我查看了节点和链表的 API,但没有找到任何东西。
有什么想法吗?
Cat------>Dog------>Horse----->Parrot
^P1 ^P2 ^P3 ^P4
Draw the resulting linked list after executing the following statements:
P4 = P2;
P3.info = P2.info
etc.
My question is, what does '.info' reference?
I've looked in the API for both node and linked list and haven't found anything.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这完全取决于您的作业中使用的具体实现,但听起来
info
包含链表中特定节点的数据,即P1.info
是 <代码>猫。This would entirely depend on the specific implementation used in your assignment, but it sounds like
info
contains the data of the specific node in the linked list, i.e.P1.info
isCat
.标准链表中的每个节点都有两条信息:
我不确定您的讲师是否希望您考虑必须“克隆”该节点为了拥有具有相同数据的单独对象,或者如果您的讲师希望您从字面上理解,将一个对象设置为等于另一个对象只是使第一个对象成为对第二个对象的引用。
正如 spookyjon 所说,信息似乎是数据(猫、狗、马、鹦鹉)的节点类中的公共变量。
Each node in a standard linked list has two pieces of information:
I'm not sure if your instructor wants you to take into account that you would have to "clone" the node in order to have a separate object with the same data or if your instructor wants you to take it literally where setting one object equal to another object simply makes the first one a reference to the second one.
As spookyjon said, the info appears to be a public variable in the node class for the data (cat, dog, horse, parrot).