0
如何更正此错误?创建简单的链接列表
Error: Node cannot be resolved to a type;
我的代码是这样的:
public class Linkedlist
{
private Node head;
private int listCount;
}
如何更正此错误?创建简单的链接列表
Error: Node cannot be resolved to a type;
我的代码是这样的:
public class Linkedlist
{
private Node head;
private int listCount;
}
public class Linkedlist {
private Node head;
private int listCount;
}
public class Node{
}
你需要确保Node
是入店
错误消息“对象不能被解析为一个类型”指示编译器无法找到需要实例化的给定对象的声明。换句话说,编译器无法确定创建节点需要读取哪些蓝图。
要解决这个问题,您有两个简单的选项。
将节点声明为LinkedList中的嵌套类。
public class LinkedList{
private Node head;
private int listCount;
}
private class Node {
//Include instance variables and constructor
}
}
将节点声明为同一目录中另一个java文件中的公共类。
public class Node{
}
缺少'进口Node'? – Emz
此问题缺少语言标记。因此不可能知道这应该是什么语言。请添加[tag:C++],[tag:java]或其他标签。 – dfeuer