I write a normal class
public class TestAccess {
}
class T{
private int i=0;
int j=0;
protected int k=0;
public int m=0;
}
class TT
{
public void m(){
T t= new T();
t.j=9;
}
}
Then I access it in the same directory with another class
public class TestProtected extends T
{
public void method(){
System.out.println(k);
}
public static void main(String[] args)
{
System.out.println("HW!");
}
}
But when I use package in the second class, there is something wrong to access class T;
package m;
public class TestProtected extends T
{
public void method(){
System.out.println(k);
}
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
Can you guys tell me how I can access class T in package m?
The issue here is not related with public, I have tried, to be more general, what if you only have class T instead of its java code? The situation is you can access the T class without package, but you cannot access it with package.