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

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();
}
}
...全文
27 2 点赞 打赏 收藏 举报
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
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();
}
}

  • 打赏
  • 举报
回复
相关推荐
发帖
非技术区
创建于2007-09-28

2.3w+

社区成员

Java 非技术区
申请成为版主
帖子事件
创建了帖子
2011-10-22 01:36
社区公告
暂无公告