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 955587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:24:15+00:00 2026-05-16T00:24:15+00:00

What would be the best way to check in an object being passed into

  • 0

What would be the best way to check in an object being passed into a method extended a given class?

Currently i have a method that takes a ByteBuffer of data to send and a ‘player’ class that i wrote, and queues the data up on the IO server to be sent to the client:

public void send(ButeBuffer toSend, Player player)
{
  // prep the byte buffer for sending, and queue it on the IO server
}

What i would like to be able to do is let the player object passed in be any object that extends the player class. I have done some searches and found something like this:

public void send(ByteBuffer toSend, Player<? extends Player> player)
{   
   // prep the byte buffer for sending, and queue it on the IO server
}

But that is giving me compile errors, and i don’t understand exactly whats going on. Would this be the proper way to do this? And if so, could anyone explain what this code is specifically doing and why it isn’t working and or link me to an article that explains this in greater detail.

Alternatlly, I suppose i could set it up something like this:

public void send(ByteBuffer toSend, Object player)
{
  // Check that the player extends Player, using instanceof or something 
  // along those lines   

  // Prep the ByteBuffer, and queue the data to send
}

However, that code feels kind of brittle to me, compared to the above code.

Any help is most welcome.
Thanks 🙂

  • 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-16T00:24:16+00:00Added an answer on May 16, 2026 at 12:24 am

    If I am not mistaken, you can keep the first syntax (expecting a Player object) and it would work with any sub-class of Player. That’s polymorphism.

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

Sidebar

Related Questions

What would be the best way to ask Propel to check whether existing object
What would be the best way and more idiomatic to break a string into
I dont know what is the best way to check if my object in
I have a method that accepts a parameter obj of type System.Object Now I
I have a validation class which I would like to use to check all
What is the best way to check if table exists in DynamoDb? I would
What would be the best way to determine if an object equals number zero
postgres 9.2 supports json columns. what would be best way to extend postgres to
I want to make a code snippet database web application. Would the best way
What would be the best way to something like this where a timestamp is

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.