有没有办法修改构造函数中构造的类?
public class A {
A() {
//if (condition) return object of type B
//else return A itself
}
}
public class B extends A { }
Run Code Online (Sandbox Code Playgroud)
基本上我想使用基类构造函数作为工厂方法.在java中有可能吗?
| 归档时间: |
|
| 查看次数: |
1301 次 |
| 最近记录: |