Is there a way to modify the class being constructed in a constructor?
public class A {
A() {
//if (condition) return object of type B
//else return A itself
}
}
public class B extends A { }
Basically I want to use the base class constructor as a factory method. Is it possible in java?