Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6792767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:00:42+00:00 2026-05-26T18:00:42+00:00

Java will not allow me to extend from ByteBuffer because it implements abstract methods

  • 0

Java will not allow me to extend from ByteBuffer because it implements abstract methods that I am not overriding, yet these methods work for any ByteBuffer objects that are created, such as asDoubleBuffer()…

byte[] bytes = new byte[256];
ByteBuffer buf = ByteBuffer.wrap(bytes);
DoubleBuffer db = buf.asDoubleBuffer();

Yet, if I extend a new class from ByteBuffer, it forces me to implement asDoubleBuffer(), even though the superclass already implements this method, obviously, since I can call it just fine. I’m totally not understanding what’s going on here… Please explain this to me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:00:43+00:00Added an answer on May 26, 2026 at 6:00 pm

    The ByteBuffer factory method returns a class which implements ByteBuffer.

    byte[] bytes = new byte[256];
    ByteBuffer buf = ByteBuffer.wrap(bytes);
    System.out.println(buf.getClass());
    

    prints

    class java.nio.HeapByteBuffer
    

    Using ByteBuffer is a relatively advanced tool, you need to understand Java pretty well before you try to extend it IMHO.


    You can see this by looking at the code. In my IDE you can find it by doing a <shift>+<click> on the method.

    public static ByteBuffer wrap(byte[] array) {
        return wrap(array, 0, array.length);
    }
    

    calls

    public static ByteBuffer wrap(byte[] array,
                                    int offset, int length)
    {
        try {
            return new HeapByteBuffer(array, offset, length);
        } catch (IllegalArgumentException x) {
            throw new IndexOutOfBoundsException();
        }
    }
    

    BTW: I am a big fan of using ByteBuffer, however you really need to understand what you are doing to use it. esp when parsing data from a ByteBuffer. Developers with ten years experience find it tricky to use.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Would like to make anapplication in Java that will not automatically parse parameters used
I'm attempting to create a java program that will allow me access to an
I am looking for a Java tool/package/library that will allow me to force-kill a
Certain methods in Java will block until they can do something, like ServerSocket.accept() and
Please understand firstly that I fully understand that Java will return a String when
As we all know Java program will start executing from the public static void
I'm writing a small agent in java that will play a game against other
Are there any libraries out there for Java that will accept two strings, and
Is there an existing application or library in Java which will allow me to
We're looking for a solution that will allow us to use HTTPS without encryption.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.