写一个程序,输出你的姓名、年龄、所在学院、所在专业、所在班级
姓名:张三
年龄:20
所在学院:计算机学院
所在专业:计算机科学与技术
所在班级:1班
public class Person {
String name;
int age;
String school;
String major;
String clas;
public Person(String name, int age, String school, String major, String clas) {
this.name = name;
this.age = age;
this.school = school;
this.major = major;
this.clas = clas;
}
Person() {
}
public static void main(String[] args) {
Person p =new Person("张三",20,"计算机学院","计算机科学与技术","1班");
System.out.println("姓名: " + p.name);
System.out.println("年龄: " + p.age);
System.out.println("所在学院: " + p.school);
System.out.println("所在专业: " + p.major);
System.out.println("所在班级: " + p.clas);
}
}
这也太简单了吧,上课没听是不,老妹。现在在外面,你可以关注下我,我明天早上帮你写完