According to this tutorial in the Java documentation, public members can be accessed on the Class, Package, Sublcass, and World levels. But say I create two classes like so:
public class TesterClass
{
public int someNumber = 5;
}
public class AnotherClass
{
public static void main( String [] args )
{
System.out.println( someNumber );
}
}
and save them in the same location. When AnotherClass
is compiled, an error is thrown saying that the variable someNumber
cannot be recognized. Why, then, does the Java docs state that public access modifiers allow access everywhere? I understand that I am doing something wrong, but what exactly is going on?