Sunday, March 27, 2011

How to avoid java " Class Cast exception occurs @ ArrayList,toArray()"

Very simple way to avoid class cast exception which occurs at the run time when we use "ArrayList.toArray()" function is,
Object[] objArray = mylist.toArray(new Entry[mylist.size()]);
 Entry[] entry = (Entry[]) objArray;


Here 'Entry' is a class object ..

No comments:

Post a Comment