有问题想要请教一下大家
import java.util.*;class Person
{
private String name;
private int age;
public Person()
{
System.out.println("调用了个人类的构造方法Person()");
}
public void setNameAge(String name,int age)
{
this.name=name;
this.age=age;
}
public void show()
{
System.out.println("姓名:"+name+" 年龄:"+age);
}
}
class Student extends Person
{
private String department;
public Student()
{
System.out.println("调用了学生类的构造方法Student()");
}
public void setDepartment(String dep)
{
department=dep;
System.out.println("我是"+department+"的学生");
}
}
public class App8_1
{
public static void main(String[] args)
{
String name,depart;
int age;
Scanner reader=new Scanner(System.in);
System.out.print("请输入姓名:");
name=reader.nextLine();
System.out.print("请输入年龄:");
age=reader.nextInt();
System.out.print("请输入学院名称:");
depart=reader.nextLine();//????????运行时depart得不到输入
Student stu=new Student();
stu.setNameAge(name,age);
stu.show();
stu.setDepartment(depart);
}
}