Java insuring that an object passed to a method extends a given class -
What would be the best way to increase the given class to pass an object in an object?
At present, I have a method that takes a bytebuff data to send and a 'Player' class I wrote, and data queues on the IO server sent to the customer:
sending a public Zero (BitBuffer Sedned, Player Player) {// Submit a byte buffer to send prepaid, and it queue on the Io server)
I What do I want to be able to do in the player object Put Bjekt that player enhances the class. I did some searches and found something like this:
to send public zero (send bytebuffer, player> player increases; player) {// to submit Byte buffer rendering, and in line it is IO server}
but it is compiling errors to me, and I do not understand exactly what is going on. What would be the proper way to do this? And if so, then someone can explain what this code is doing specially and why it is not working or is linking me to an article which tells it in more detail.
Alternatlly, I think I can set it something like this:
sending a public zero (to send a bytebuffer, object player) {// check Make sure that the player extends the player, with example or some other // those lines // Preparation bytebuffer, and
However, that code seems to me to look brittle than above Used to be.
Any help is most welcome thanks
If I'm not wrong So, you can keep the syntax first (expecting a player object) and it will work with any subclass of the player. This is polymorphism.
Comments
Post a Comment