帮我看下这个代码 编译提示需要'{' 本人菜鸟 望高手解答

a313185120 2011-10-22 01:36:46
public abstract class Student {
private String name;
private String no;
public abstract void printlnfo() {

}
public Student() {
no="20100701020xx";
name="lx";
}
public static void print() {
System.out.println("name:" +name);
System.out.println("no:" +no);
}
}

public class MaleStudent extents Student {
private String gender;
public MaleStudent(String gender) {
this.gender=gender;
}
public static void printlnfo() {
System.out.println("name:"+name);
System.out.println("no:+no");
System.out.println("gender:+gender");
}
public static void main(String[] args) {
MaleStudent m=new MaleStudent();
printlnfo();
}
}
...全文
63 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Paradise_heida 2011-10-22
  • 打赏
  • 举报
回复
风尘中国 2011-10-22
  • 打赏
  • 举报
回复
有很多地方需要改动,代码贴到下面你自己找一下问题吧,看你语法还是很生疏,找本教材学习下


abstract class Student {
private String name;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getNo() {
return no;
}

public void setNo(String no) {
this.no = no;
}

private String no;
public abstract void printlnfo();

public Student() {
no="20100701020xx";
name="lx";
}
public void print() {
System.out.println("name:" +this.getName());
System.out.println("no:" +no);
}
}

public class MaleStudent extends Student {
private String gender;

public MaleStudent(String gender) {
super();
this.gender=gender;
}
@Override
public void printlnfo() {
System.out.println("name:"+this.getName());
System.out.println("no:+no");
System.out.println("gender:+gender");
}
public static void main(String[] args) {
MaleStudent m=new MaleStudent("man");
m.printlnfo();
}
}

23,409

社区成员

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

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