samedi 10 janvier 2015

Why I cannot access class after I use package?


Vote count:

0




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?



asked 1 min ago

ZHI

1






Why I cannot access class after I use package?

Aucun commentaire:

Enregistrer un commentaire