4
這裏是我的簡單的類引用:的Java不能從靜態上下文
public class Project {
private int size;
private Obj tree;
static Obj insert(Obj t, String s) { // t is null
t = new Obj();
t.val = s;
return t;
}
public Project()
{
Obj tree = new Obj();
int size=0;
}
public class Obj
{
public String val;
public Obj()
{
val=null;
}
}
}
然而,當我嘗試插入()函數來創建新的對象,我得到這個錯誤:
Error: non-static variable this cannot be referenced from a static context
啊哈,非常感謝。我會盡可能標記你的答案。 – Firkamon 2015-03-18 23:58:31