Another way I got around is to create another class to hold the Variable variable, and then create an array of that class for example.
public class test<T>{ data[] localVar = new data[1]; private class data<E>{ E info; public data(E e){ info = e; } } public void add(T e){ localVar[0] = new data<T>(e); } }
the code above cannot be used for anything practical unless you want to add one element to the array, but it just shows the idea.
source share