Possible Duplicate:
Converting an array of objects to an array of their primitive types
I making a Parcel for Android and I’m trying to package an ArrayList<Long> (toArray gives me Long[]) by converting it to long[], is there a simple way to do this?
I realize I can loop through but I guess I’m looking for a more elegant solution.
Unfortunately there is no easier way than looping. This post is about doing the opposite but the idea is the same…
Since another answer recommends Apache Commons and you are on Android – if I were to include an additional dependency I would rather go for guava Longs utility class:
For reference, the code is: