crysis crysis - 5 months ago 19x
Java Question

How to pass Object ArrayList through interface?

I've an interface defined as

public interface QueryCompleteListener {
void onQueryCompleted(int token, ArrayList<Object1> songList);

I'm using this interface to return callback. In some callbacks I want to pass
and in some cases I want to pass
through the interface.

If I declare interface method as

void onQueryCompleted(int token, ArrayList<Object> songList)

to pass any type of Object, it gives an error saying found Object1 required Object when I call this method by passing


Use following:

<T> void onQueryCompleted(int token, List<T> songList); 

See Generic Methods for more details.