当我在 Java 上工作时,我试图创建一个 Node 类数组。为了指定大小,我之前使用过 int,它工作正常,但是当我更改为 long 时,它给了我编译错误。请检查下面的代码。
public class Simple {
long maxsize = 7657567579l; // it fails when i tried to use value out-of-range of int
Node[] nudes = new Node[maxsize];
public static void main(String[] args) {
Simple simple = new Simple();
}
}
class Node {
public Object data;
public long next;
public Node(Object data, long next) {
super();
this.data = data;
this.next = next;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
public long getNext() {
return next;
}
public void setNext(int next) {
this.next = next;
}
}
ABOUTYOU
相关分类