-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
8u51
-
x86
-
os_x
A DESCRIPTION OF THE REQUEST :
ArrayList.toArray() currently returns an Object[], making it overly complicated to convert an ArrayList to an array.
JUSTIFICATION :
It is overly complicated to convert an ArrayList<String> to a String[] because the toArray method returns an Object[]
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Given an ArrayList<String>, stringList, stringList.toArray() should return a String[].
ACTUAL -
Given an ArrayList<String>, stringList, stringList.toArray() returns an Object[]
---------- BEGIN SOURCE ----------
ArrayList<String> stringList = new ArrayList<String>();
stringList.add("Hello");
stringList.add("World");
Object[] array = stringList.toArray(); // toArray returns an Object[] instead of a String[]
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Given an ArrayList<String>, stringList, calling stringList.toArray(new String[0]); returns a String[]
ArrayList.toArray() currently returns an Object[], making it overly complicated to convert an ArrayList to an array.
JUSTIFICATION :
It is overly complicated to convert an ArrayList<String> to a String[] because the toArray method returns an Object[]
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Given an ArrayList<String>, stringList, stringList.toArray() should return a String[].
ACTUAL -
Given an ArrayList<String>, stringList, stringList.toArray() returns an Object[]
---------- BEGIN SOURCE ----------
ArrayList<String> stringList = new ArrayList<String>();
stringList.add("Hello");
stringList.add("World");
Object[] array = stringList.toArray(); // toArray returns an Object[] instead of a String[]
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Given an ArrayList<String>, stringList, calling stringList.toArray(new String[0]); returns a String[]