Даже самые уродливые хаки, которые я могу придумать, отклоняются компилятором:
Код: Выделить всё
class Base
{
Base(String someParameter)
{
System.out.println(this);
}
}
class Derived extends Base
{
private final int a;
Derived(String someParameter)
{
super(hack(someParameter, a = getValueFromDataBase()));
}
private static String hack(String returnValue, int ignored)
{
return returnValue;
}
public String toString()
{
return "a has value " + a;
}
}
Подробнее здесь: https://stackoverflow.com/questions/156 ... uctor-runs
Мобильная версия