package class_Student;
public class Student {
public static Student ms;
public String stuId;// 学号
public String stuName;// 姓名
public int stuAge;// 年龄
public String stuSex;// 性别 public Student() { }
// 重载构造函数实现对所有属性赋值
public Student(String stuId, String stuName, int stuAge, String stuSex) {
this.stuId = stuId;
this.stuName = stuName;
this.stuAge = stuAge;
this.stuSex = stuSex;
}
// 四参构造设置姓名、年龄、性别
public Student(String stuName, int stuAge, String stuSex,String stuId) {
this.stuName = stuName;
this.stuAge = stuAge;
this.stuSex = stuSex;
}package class_Student;public class TestStudent {
public static void main(String[] args) {
Student.ms = new Student();
//Student.ms = new Student(){String stuName,int stuAge, String stuSex,String stuId};
//Object ms;
Object ms;
急!!这怎幺错了???ms.stuName = new Student(String stuName){"刘军"};
public class Student {
public static Student ms;
public String stuId;// 学号
public String stuName;// 姓名
public int stuAge;// 年龄
public String stuSex;// 性别 public Student() { }
// 重载构造函数实现对所有属性赋值
public Student(String stuId, String stuName, int stuAge, String stuSex) {
this.stuId = stuId;
this.stuName = stuName;
this.stuAge = stuAge;
this.stuSex = stuSex;
}
// 四参构造设置姓名、年龄、性别
public Student(String stuName, int stuAge, String stuSex,String stuId) {
this.stuName = stuName;
this.stuAge = stuAge;
this.stuSex = stuSex;
}package class_Student;public class TestStudent {
public static void main(String[] args) {
Student.ms = new Student();
//Student.ms = new Student(){String stuName,int stuAge, String stuSex,String stuId};
//Object ms;
Object ms;
急!!这怎幺错了???ms.stuName = new Student(String stuName){"刘军"};
Object ms; 这个不应该去掉吗
new Student(String stuName){"刘军"};真没看明白这几个位置
ms.stuName是一个String类型的,你给它赋值一个Student,当然会报错了。
应该是ms.stuName = "刘军";