Convert an Object to ArrayListVisitant

0

I have a method that returns values of firebase . When received, I create a new ArrayList<Visitante > and the saved in Object .

ArrayList<Visitante> visitantes = new ArrayList<>();
                        for (DataSnapshot snapshot : dataSnapshot.getChildren()) {
                            visitantes.add(snapshot.getValue(Visitante.class));
                            Log.e("***", snapshot.getValue(Visitante.class).getNome());
                        }
event.emit(new Result(visitantes));

event.emit() expects a type Object .

How do I redraw this Object to ArrayList<Visitante> ?

    
asked by anonymous 05.12.2017 / 22:49

1 answer

0

cast from object to ArrayList<Visitante> .

array = (ArrayList<Visitante>) objecto; 

If the object is not of the indicated type, an exception of type ClassCastException

    
05.12.2017 / 23:02