Hi,
I have following code in the file NameTest.java
and this code in GetSet2.java
When I try to compile NameTest.java I get an error -
cannot access GetSet2
But if I uncomment the first line
//package TestPack;
in NameTest.java, everything works fine.
Could somebody please explain? Must a class be in a package to access another public class from a different package? But that does not seems to be true because we can import java packages and use the classes in the code.
Kiran
I have following code in the file NameTest.java
and this code in GetSet2.java
When I try to compile NameTest.java I get an error -
cannot access GetSet2
But if I uncomment the first line
//package TestPack;
in NameTest.java, everything works fine.
Could somebody please explain? Must a class be in a package to access another public class from a different package? But that does not seems to be true because we can import java packages and use the classes in the code.
Kiran