Created
December 10, 2011 12:39
-
-
Save shekhargulati/1455072 to your computer and use it in GitHub Desktop.
ArrayStoreException
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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