I have a particular condition, just need you help to verify it.
I have 2 packages, packageA and packageB. packageA has 1 default class DefaultClass and 1 public class SubClass. SubClass extends DefaultClass.
DefaultClass has a method public functionA();Now coming to packageB. It has 2 classes AccessorA and AccessorB. AccessorA extends SubClass, therefore it can access the method functionA();Now AccessorB has an instance of SubClass. But I'm not able to access functionA() using that instance.
Now, is this okay, or should I be able to access the functionA(). Because functionA() is in a default class, but it should be passed on to the SubClass. Its a bit confusing, so help me out.
My, that sounds complicated. Have you tried it? I suspect the answer is yes.
You can inherit a public method from a package‑private (=default) class, in a public class in the same package. The public method is now accessible outside the package, but only in the subclass.
posted 5 years ago
There is something not right about not being able to use that method in the other package. Please show us some code.
Run away! Run away! Here, take this tiny ad with you: