Q:

java how to pass a List for generic element in it

I want to create a Util to handle any possible type in a List, so I write this code:
class Util{
    static class Data<T>{
        String message; T raw; boolean report;
        Data(String m, T d, boolean b){ message=m; raw=d; report=b;}
    }

    interface Callback{ public void report(int idx); }

    static void handleList(List<Data> list, Callback cb){
        for(int i=0; i<list.size(); i++) if(list.get(i).report) cb.report(i);
    }

    public static void main(String[] args){
        List<Data<Float>> list = new ArrayList<Data<Float>>();
        list.add(new Data<Float>("iPhone", 3000f, false));
        list.add(new Data<Float>("iPad", 999.5f, true));
        handleList(list, new Callback(){
            @Override
            public void report(int idx){
                Data<Float> data = list.get(idx);
                System.out.println(data.message+": "+list.get(idx).raw);
            }
        });
    }
}

I cannot compile the code until I modify the method handleList with the parameter type List<Data<Float>>, but that is NOT my purpose, because I want to reuse the handleList for any type of Data in the List. What should I do?

A:

Simply use a parameterized type for the method for Data to be bound by.  
<T> handleList(List<Data<T>> list, Callback cb){
    //code
}

A:

You are almost there. Just make handleList generic:
static <L> void handleList(List<Data<L>> list, Callback cb) {
    ...

