Create an abstract class Conta
, and two other concrete classes ContaF
and ContaJ
that inherit from the main class. Create another class with a method that receives a list of contaF
and ContaJ
and ArrayList<Conta>
and calculate how many elements it has in ContaF
and ContaJ
I'm almost done:
public class InstanciaDe
{
public static void main( String[] args )
{
ContaF Rafael = new ContaF();
ContaJ Roberto = new ContaJ();
ContaJ Carlos = new ContaJ();
ArrayList<Conta> lista = new ArrayList<Conta>();
lista.add(Rafael);
lista.add(Roberto);
lista.add(Carlos);
for(int i=0 ; i < lista.size() ; i++){
if (lista.get(i) instanceof ContaF) {
}
if (lista.get(i) instanceof ContaJ) {
}
}
}
}
How can I save the quantity by instanceof
of each and then display?