1 changed files with 24 additions and 0 deletions
@ -0,0 +1,24 @@ |
|||
public class Student { |
|||
public int ID; |
|||
public String name; |
|||
public int age; |
|||
public String major; |
|||
public Student(int ID,String name,int age,String major){ |
|||
this.ID=ID; |
|||
this.name=name; |
|||
this.age=age; |
|||
this.major=major; |
|||
} |
|||
public void info(){ |
|||
System.out.println("学生学号:"+ID); |
|||
System.out.println("学生姓名:"+name); |
|||
System.out.println("学生年龄:"+age); |
|||
System.out.println("学生专业:"+major); |
|||
} |
|||
public static void main (String[] args){ |
|||
Student mary=new Student(20220933,"Mary_Jane",22,"computer_science"); |
|||
mary.info(); |
|||
Student John=new Student(20210288,"John Shark",23,"data science"); |
|||
John.info(); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue