My main method in a package by itself can only see some of the methods in the other package even though they are all public. This is an example of my code.
package stuff.code;
public class AObject
{
public AObject();
public AObject(String str);
public int getLength();
public int getHeight();
}
package stuff.code;
public class BObject extends AObject
{
public BObject();
public BObject(String str);
}
package stuff.test;
import stuff.code.AObject;
import stuff.code.BObject;
public class tester
{
AObject a = new AObject(); //no red underline
AObject aa = new AObject("some string"); //no red underline
BObject b = new BObject(); //no red underline
BObject bb = new BObject("some string"); //tells me there is no such constructor
b.getLength(); //tells me I need a getLine method in BObject too
}
I've looked into setAccessible(boolean flag) method but I didn't understand most of it and it was still undefined after I imported java.lang.reflect.AccessibleObject.
This is not my actual code. I wanted this to be vague so that an answer would be more useful to many other people that run into this problem. My methods are all concrete with a body but the body isn't the issue. It runs fine when everything is in the same package but the tester class must be in a different package.