类引用自己要加static修饰吗
public class aa
{
public static void main(String[] args)
{
xx a = new xx();
a.getC();
System.out.println("dd");
}
}
class xx
{
xx ekao = new xx();//这里不加static修饰会报java.lang.StackOverflowError Exception
public xx()
{
System.out.println("ok");
}
public void getC()
{
System.out.println("bb");
}
}
这是为什么?谢谢