关于覆写(overridding)抽象方法的问题 子类不能访问父类的private成员不能在static方法中调用非static方法 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 子类不能访问父类的private成员static方法中不能调用非static方法,应该先生成实例: AbstractExample example = new AbstractExample(); example.setString("Overridding the abstract method getString()"); example.getString(); 除了楼上说的外,还要在AbstractExample中的最前面加上private String s; private类型的成员是不能被子类直接引用的,你可以把它定义为protected的。下面两个错吗,你没有在main里new AbstractExample(),怎么能直接用它的方法呢? 每日一题 简单提问在线等:类加载 基于组播的对等网资源共享程序 怎样使画的一张图片不用组件响应事件? 初学者 接口理解问题 请问参数个数不定在java里面除了用数组 有其他根本的解决方法吗?,期待高人解决。 关于java调c函数 请问在JAVA中如何执行dos命令 关于weblogic的问题!!!!! 动态绑定如何实现? robocode执行错误 一个简单的继承上的问题求解
static方法中不能调用非static方法,应该先生成实例:
AbstractExample example = new AbstractExample();
example.setString("Overridding the abstract method getString()");
example.getString();
private String s;
下面两个错吗,你没有在main里new AbstractExample(),怎么能直接用它的方法呢?