在jcreator中遇到的问题,请高手赐教

JPtler 2004-04-01 12:23:02
代码1-----------------
package people;
public class people{
public people (String name){
......
}
public people(String name, String sex){
......

}

public String getName(){
return name;
}

public String getSex(){
return sex;
}

private String name;
private String sex;

}

代码2---------------------
package people;

import people.people;

public class chinese extends people{
public chinese(String aName,String aSex){
super(aName,aSex);
}
public chinese(String aName,String aSex, int aAge){
super(aName, aSex);
age = aAge;
}

public void getPersonalInformation(){
System.out.print("name is :" + super.getName() +"\n" + "age is:" + age);
if (super.getSex() == "female")
System.out.println("she is a female");
else
System.out.println("he is a male");
}
private int age;
}
代码3------------------------
import people.*;

public class testpeople{
public static void main(String [] args){
chinese ren_1 = new chinese("beidou", "boy", 21);
System.out.println(ren_1.getPersonalInformation());
}
}

编译代码3的时候,出现一下错误:
F:\Testfield\people\testpeople.java:5: cannot access chinese
bad class file: F:\Testfield\people\chinese.java
file does not contain class chinese
Please remove or make sure it appears in the correct subdirectory of the classpath.
chinese ren_1 = new chinese("zhangyu", "boy", 21);

请高手指教,谢谢!

...全文
43 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
Leemaasn 2004-04-08
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/TopicView1.asp?id=2940187
阎罗 2004-04-01
  • 打赏
  • 举报
回复
你的getPersonalInformation()函数里面已经有输出了,可以直接调用就行
import people.chinese;


public class testpeople{
public static void main(String [] args){
chinese ren_1 = new chinese("beidou", "boy", 21);
ren_1.getPersonalInformation();
}
}
阎罗 2004-04-01
  • 打赏
  • 举报
回复
你应该在第三个程序前加上import people.chinese;
然后你的System.out.println(ren_1.getPersonalInformation());也是错误的,你的
getPersonalInformation()是void类型,不返回任何值,而System.out.println()里面是string类型的
gernett21 2004-04-01
  • 打赏
  • 举报
回复
你的chinese类放在哪里了?先编译它再编译3
JPtler 2004-04-01
  • 打赏
  • 举报
回复
非常感谢各位。
battyht 2004-04-01
  • 打赏
  • 举报
回复
import people.chinese;就可以了,一个class文件找不到的
或者要在classpath里面加入你的path!

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧