Discuss
/
Java
/
Cannot make a static reference to the non-static method getClass() from the type Object
Cannot make a static reference to the non-static method getClass() from the type Object
Topic source目的是调用Class.getResourceAsStream()所以先获取Class实例:
如果你有一个实例当然调用 this.getClass().getResourceAsStream()
如果在static方法里没有实例那就用 Prop.class.getResourceAsStream()
学到这了还解决不了基础问题就得回去补补
- 1
super阳光的麦穗77
同学们难道没有出现类似的错误吗?在main方法里面调用getClass()的时候?