• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps asFloatBuffer

jcarsw04

Newbie
I want to convert a ByteBuffer to hold Floats. I noticed the method ByteBuffer.asFloatBuffer() would do the job but it's declared as abstract. Does this mean that I need to provide an implementation of the method somewhere? If so, how would you implement this? If not, where would the implementation be provided? Thanks for your help.
 
You can't have an actual ByteBuffer object because the ByteBuffer class is abstract. What you'll actually have an object of a concrete subclasss of ByteBuffer. This subclass will have provided the implementation of asFloatBuffer().

Note that asFloatFloat() won't convert the underlying bytes from chars to floats. It will just return an object which will be a concrete subclass of FloatBuffer, and that will simply just start interpreting the remaining, unread bytes in the buffer as floats instead of as chars.
 
Back
Top Bottom