java简单个一个小程序 错在哪里啊!提示少了个 “{”
abstractclassPerson{privateStringname;privateintage;publicPerson(Stringname,intage){t...
abstract class Person{
private String name;
private int age;
public Person(String name,int age){
this.name = name;
this.age = age;
}
public void setName(String name){
this.name = name;
}
public void setAge(int age){
this.age = age;
}
public String getName(){
return this.name;
}
public int getAge(){
return this.age;
}
public void print();
};
class Student extends Person(){
private String school;
public Student(String name,int age,String school){
super(name,age);
this.school = school;
}
public void setSclool(String school){
this.school = school;
}
public String getSchool(){
return this.school;
}
public void print(){
System.out.println(super.getName()+","+super.getAge()+","+this.getSchool());
}
};
public class AbstractDemo02{
public static void main(String args[]){
Student stu = new Student("chengchao",24,"hefeixueyuan");
stu.print();
}
};
class Student extends Person(){ 提示的是这一行附近。 展开
private String name;
private int age;
public Person(String name,int age){
this.name = name;
this.age = age;
}
public void setName(String name){
this.name = name;
}
public void setAge(int age){
this.age = age;
}
public String getName(){
return this.name;
}
public int getAge(){
return this.age;
}
public void print();
};
class Student extends Person(){
private String school;
public Student(String name,int age,String school){
super(name,age);
this.school = school;
}
public void setSclool(String school){
this.school = school;
}
public String getSchool(){
return this.school;
}
public void print(){
System.out.println(super.getName()+","+super.getAge()+","+this.getSchool());
}
};
public class AbstractDemo02{
public static void main(String args[]){
Student stu = new Student("chengchao",24,"hefeixueyuan");
stu.print();
}
};
class Student extends Person(){ 提示的是这一行附近。 展开
4个回答
展开全部
abstract class Person{
private String name;
private int age;
public Person(String name,int age){
this.name = name;
this.age = age;
}
public void setName(String name){
this.name = name;
}
public void setAge(int age){
this.age = age;
}
public String getName(){
return this.name;
}
public int getAge(){
return this.age;
}
public abstract void print();
}
class Student extends Person{
private String school;
public Student(String name,int age,String school){
super(name,age);
this.school = school;
}
public void setSclool(String school){
this.school = school;
}
public String getSchool(){
return this.school;
}
public void print(){
System.out.println(super.getName()+","+super.getAge()+","+this.getSchool());
}
}
public class AbstractDemo02{
public static void main(String args[]){
Student stu = new Student("chengchao",24,"hefeixueyuan");
stu.print();
}
}
private String name;
private int age;
public Person(String name,int age){
this.name = name;
this.age = age;
}
public void setName(String name){
this.name = name;
}
public void setAge(int age){
this.age = age;
}
public String getName(){
return this.name;
}
public int getAge(){
return this.age;
}
public abstract void print();
}
class Student extends Person{
private String school;
public Student(String name,int age,String school){
super(name,age);
this.school = school;
}
public void setSclool(String school){
this.school = school;
}
public String getSchool(){
return this.school;
}
public void print(){
System.out.println(super.getName()+","+super.getAge()+","+this.getSchool());
}
}
public class AbstractDemo02{
public static void main(String args[]){
Student stu = new Student("chengchao",24,"hefeixueyuan");
stu.print();
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
第20行少{},改成
public void print()
{
}
public void print()
{
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
上面是对的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |