Collection interface posses method
By default toArray method provide service of returning of Object array (Object[]). If this is not what we want and we knows type of the array, then we can provide our type and avoid explicit converting.
To do that, we need to provide array type and instance of that array type like so:
Listlist = new ArrayList (); String[] stringList = (String[])list.toArray(new String[list.size()]);
Please see details in Java API
No comments:
Post a Comment