class a{
public void a(){
System.out .print("adsf");
}
}
public class PublicMother extends Thread {
a b;
public void run (){
b.a();
}
public static void main(String[] args){
PublicMother c=new PublicMother();
c.start();
}
}简单来说就是:为什么run方法中不能调用a()方法能??
我是刚刚学java的虾米 希望有大侠能详细的赐教一下 或给个好资源让我补习补习!!谢谢!!
public void a(){
System.out .print("adsf");
}
}
public class PublicMother extends Thread {
a b;
public void run (){
b.a();
}
public static void main(String[] args){
PublicMother c=new PublicMother();
c.start();
}
}简单来说就是:为什么run方法中不能调用a()方法能??
我是刚刚学java的虾米 希望有大侠能详细的赐教一下 或给个好资源让我补习补习!!谢谢!!
a b = new a();
这里你只创建了引用,并没有new出资源。
所以编译都出错了吧?