0
I have an object from the Account class "Account Lectured" however, using polymorphism daughter classes are assigned to Lectured.
public AlterarLimites(Conta conta) {
contaSelecionada = conta;
type = 1;
initComponents();
}
public AlterarLimites(Poupanca conta) {
contaSelecionada = conta;
type = 2;
initComponents();
}
public AlterarLimites(Salario conta) {
contaSelecionada = conta;
type = 3;
initComponents();
}
however I cannot access exclusive methods of the child classes of Account in this way. what could I do to access them?
is missing code and an object declared as
Conta
you want to access something exclusive ofContaSelecionada
, that’s it ?– Rovann Linhalis
Basically that’s what’s explained in the duplicate, it’s a covariance problem, which means you can’t treat a supertype with a subtype.
– user28595