is there a way
Paul Beckett wrote:if you want to change a List<Integer> into an Integer you can try the Collection.toArray(T) method. This uses generics so is java1.5 and later only.
Have a look at the javadoc for this to understand its behaviour - it may not be exactly what you need (ie it does not give you an array of primitives).
However, I'd probably approach this problem by creating the array manually and then iterating over the list to populate the array.
Harshana Dias wrote:
Just try following and still showing Type mismatch: cannot convert from Object to String. Shouldn't generics recognized and make a String array..
Campbell Ritchie wrote:How can a zero-length array not be empty? The memory use will be minimal.
Mike Jensen wrote:I like to use the IntArrayList from Colt. (http://acs.lbl.gov/~hoschek/colt/)
Colt provides a set of Open Source Libraries for High Performance Scientific and Technical Computing in Java.
Api for the IntArrayList is: http://acs.lbl.gov/~hoschek/colt/api/cern/colt/list/IntArrayList.html
The Colt library has more goodies than this, check it out