关于用Eclipse编写Java程序的一个问题 5
直接说主题吧,这是我写的2类:publicclassPeople{doubleheight,weight;People(){System.out.println("str...
直接说主题吧,这是我写的2类:
public class People {
double height,weight;
People(){System.out.println("structure People");}
void run(){System.out.println("run");}
void sleep(){System.out.println("sleep");}
}
public class ChinaPeople extends People {
ChinaPeople(){
super ();
System.out.println("structure ChinaPeople");
}
void chinaGongfu(){System.out.println("Gongfu");}
}
上面都在一个包里,然后我建一个类测试一下
public class Example_01 {
public static void main(String args[]){
ChinaPeople b2;
b2=new ChinaPeople();
}
}
输出结果
structure People
structure ChinaPeople
这都没问题,然后我修改了一下
public class Example_01 {
public static void main(String args[]){
ChinaPeople b2=new ChinaPeople();
}
}
编译OK,这种方法也应该对。问题是没有输出结果,我估计是构造过程哪不对,所以没出结果。有哪个给我指点一下吗。讲下原因,思路也行 展开
public class People {
double height,weight;
People(){System.out.println("structure People");}
void run(){System.out.println("run");}
void sleep(){System.out.println("sleep");}
}
public class ChinaPeople extends People {
ChinaPeople(){
super ();
System.out.println("structure ChinaPeople");
}
void chinaGongfu(){System.out.println("Gongfu");}
}
上面都在一个包里,然后我建一个类测试一下
public class Example_01 {
public static void main(String args[]){
ChinaPeople b2;
b2=new ChinaPeople();
}
}
输出结果
structure People
structure ChinaPeople
这都没问题,然后我修改了一下
public class Example_01 {
public static void main(String args[]){
ChinaPeople b2=new ChinaPeople();
}
}
编译OK,这种方法也应该对。问题是没有输出结果,我估计是构造过程哪不对,所以没出结果。有哪个给我指点一下吗。讲下原因,思路也行 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询