一个简单程序的错误,谢谢您来纠正

butter0000 butter0000 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
class Node{
int date;
Node next;
}
public class list {


public static void main(String[] args) {

try {
for(int i=0;i <3;i++)

{
Node nd=new Node();
nd.date=i;
nd=nd.next;
System.out.println(nd.date);
}
for(int j=0;j <3;j++)
{
System.out.println(nd.date);
nd=nd.next;
}

} catch (Exception e) {

}

就是想用java来实现一个链表,可是那个对象只能在那个for循环里面有效。在红的for循环就无效了,怎么把这个链表存储下来。然后在哪里都能输出呢?谢谢回答!
...全文
评论 14
收藏 已收藏
分享
返回顶部
butter0000
Java SE 62,620 成员 307,251 内容