Skip to content

Instantly share code, notes, and snippets.

@shekhargulati
Created December 10, 2011 12:39
Show Gist options
  • Save shekhargulati/1455072 to your computer and use it in GitHub Desktop.
Save shekhargulati/1455072 to your computer and use it in GitHub Desktop.
ArrayStoreException
public class GenericsPlay<T> {
public void toArray(T t){
T[] array = (T[])Array.newInstance(t.getClass(), 100);
Object[] objs = array;
List<Double> doubles = new ArrayList<Double>();
doubles.add(Double.valueOf(12.4));
objs[0] = doubles;
}
public static void main(String[] args) {
GenericsPlay<String> obj = new GenericsPlay<String>();
obj.toArray("shekhar");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment