The Problem: I collect a unknown number of shorts
into a ArrayList<Short>
. When finished I need to put it into a direct ShortBuffer
.
My Solution: Writing a simple loop.
But in my final Code, this will be done only once and it is not timecritical. In such a case, I always prefer a solution that needs less code.
Can it be done in a one or two liner?
Edit:
With ArrayList<Short>.toArray
I can get a Short[]
array, but for ShortBuffer.put()
I need a short[]
array. That is the problem.