Type Mismatch: cannot convert from Object to ObjectName

22 views Asked by At

I have a Class named Filial. On my Main class, i created a ArrayList of it:

ArrayList<Filial> filiais = new ArrayList<Filial>();

Still on my Main, i created a method:

    public static void atualizaFiliais(ArrayList filial){
        Filial thisFilial = filial.get(0); // <======Error

But i get this error when i try do this, thats say:

'Type mismatch cannot convert from Object to Filial'

Why cant i do this?

I also tried to set its attributes but also get error, for example:

Filial.java

public class Filial {
    String nome, endereco, contato, codigo;

Main.java

   public static void atualizaFiliais(ArrayList filial){
             String txta;
             txta = filial.get(0).nome //<====== Error

in that case it happens to appear the error on nome:

'nome cannot be resolved or is not a field'

0

There are 0 answers