public class A {
public static void main(String[] args) throws Exception {
ReadFile file = null;
Properties fileContent = null;
try {
// read test file content.
file = new ReadFile(FILE);
// file is exist.
if (file.init()) {
B b = new B();
fileContent = file.getHeads();
b = setb(fileContent);
System.out.println("super bb="+b.getAlgorithm());
C c = new C();
System.out.println("client aa="+c.getAlgorithm());
}
} catch(Exception e) {
System.out.println("error="+e);
throw e;
}
}
其中C类是继承是B类的,我认为在b = setb(fileContent);这个函数中已经给B的对象进行了复值的操作,为什么b.getAlgorthm()可以得到的内容但是继承自他的C 中c.getAlgorithm();就不能得到内容呢?? 请大家帮忙,谢谢各位了!
public static void main(String[] args) throws Exception {
ReadFile file = null;
Properties fileContent = null;
try {
// read test file content.
file = new ReadFile(FILE);
// file is exist.
if (file.init()) {
B b = new B();
fileContent = file.getHeads();
b = setb(fileContent);
System.out.println("super bb="+b.getAlgorithm());
C c = new C();
System.out.println("client aa="+c.getAlgorithm());
}
} catch(Exception e) {
System.out.println("error="+e);
throw e;
}
}
其中C类是继承是B类的,我认为在b = setb(fileContent);这个函数中已经给B的对象进行了复值的操作,为什么b.getAlgorthm()可以得到的内容但是继承自他的C 中c.getAlgorithm();就不能得到内容呢?? 请大家帮忙,谢谢各位了!
解决方案 »
- 请教各位前辈!!!if.else基础题目!!主要求教解题思路。。。
- 怎么用js数组给单选按钮后面显示的名称赋值?
- java.sql.SQLException: The SQL statement must not be null or empty.
- 类字段、类方法、实例字段、实例方法
- java连接SQL问题
- 有谁可以告诉我--孙鑫著<JAVA无难事>视频哪里可以下载?
- BMP问题求解
- 求源码:类似于qq的即时聊天,可发邮件,可传文件,感动期待中
- 出学JAVA 有几个问题 JAVA前辈请进 在线等待 14点结贴
- 类包不存在怎么办?
- 请问jEditorPane如何知道用户正在看第几行?
- 请教一个问题,怎么解决?
public String i = null;
void setA(String a) {
i = a;
}
String getA() {
return i;
}
} class B extends A {
int k;
} public class test {
public static void main(String[] args) {
A superOb = new A();
B subOb = new B();
System.out.println("Contents of superOb: ");
superOb.setA("aaa");
System.out.println();
System.out.println("Contents of superOb: "+superOb.getA());
System.out.println("Contents of subOb: "+subOb.getA());
}
}
同样的问题 这个看的比较清楚 之前的太复杂了