java问题求帮,请教一下

img


上机课遇到的问题,请教一下,搞不懂静态非静态,麻烦了,编译器报错是cannot make a static reference to the non_static method In()from the type Subclass

在静态方法里是不能直接调用非静态方法的,你的NewSubClass是哪里来的,如果NewSubClass继承了SubClass,那么In方法应该通过id.In()来调用,如果没有继承,那么应该new一个SubClass的实例来调用In方法。

上机课直接问老师啊。
你这静态方法里面调非静态方法

img

1.static方法要调用static的方法
2.翻译过来也是这个意思,你的in方法不是static的

改一下
public static int In()