I have recently learned like 3 new languages and I am starting to confuse them. I have not worked Java in doing anything complicated (in android outdoors) in particular in some years. I'm having trouble remembering that this could be possible:
I'm mainly doing arterial subclasses, so I can order an array list. I am trying to override the adding object (
method, but I want it to return an intestine instead of bullion (the place of the object that was added). But I am getting errors on the return type of my method. I
Is it also possible in language? Can you separate any method in the superclass method by returning to subclass?
Or am I trying to fool some? Is it breaking up? is-a
idea of heritage? Would I just want to convert an array list instead of expanding it?
For reference, a part of what I am trying to do:
Authors of the public categoryArere spreads to ArrayList {Override Public EnAd ) {Super.and (object); collection. Source (this, new serial name ()); Turn it back. Index (object); }}
Do you have a different sub- Method of superclass?
In general, the only exception is covariant return type , when an override method returns the return type subclass in the base class / interface method. It became possible with Java 5, and is a good practice. But your case does not fall into this category.
Is this a break-up idea of inheritance?
Yes . The user of ArrayList
is expected to get the add
from the Boolean
return value, and see those elements in the order they added them Do not do that, and hope you break up.
Should I just put an array list aside instead of expanding it?
Yes. You can then set your own interface, which you want to contract, but first, consider using one instead .
Comments
Post a Comment