As for the "<T> T[] toArray(T[] a)" method, would that have worked if option 5 had instead been written
Code: Select all
String[] sa;
values.toArray(sa);
Moderators: Site Manager, fjwalraven
Code: Select all
String[] sa;
values.toArray(sa);
andIf the list fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this list.
Thus, String[] sa; values.toArray(sa); will throw a NPE.Throws:
ArrayStoreException - if the runtime type of the specified array is not a supertype of the runtime type of every element in this list
NullPointerException - if the specified array is null
Users browsing this forum: No registered users and 8 guests