Hello from Australia =]
My question is rather simple but confusing.
When i create abstract classes i alway create them so it can be extended at a later date by a normal class,
The ByteBuffer in the nio package is unable to be extended due to its private constructor. In fact the only way to extend it is to created a new abstract class, which to me, seems pointless.
If you look at the ByteBuffer's API, the majority of its methods are abstract which has me confused.
If anyone could clear this up i would be mighty greatful.

Thank you in advance
Daniel.

Recommended Answers

All 3 Replies

I would like to site you the same documentation again. You can create a ByteBuffer but there are other methods than the regular constructor to create them. Going through the docs once again, albeit more carefully would sort this out for you.

I didn't notice any private constructor in ByteBuffer and I don't there should be any since it is an abstract class. You are not supposed to initialize it

There are many classes in the java.nio package which have package visibility and hence don't show up in the Javadocs. Look into the Java standard library source in the java.nio package for more details on how to extend the ByteBuffer / MappedByteBuffer classes.

BTW, clicking on the USE link when browsing the Javadocs of a given class gives you complete information on all the classes which refer the given class, just in case...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.