手撸出来的,觉得不错就采纳(当然,最好自己也去打,对你有好处)
public class Student {
private String name;
private int stuNum;
private String birthday;//出生日期Date类型也好
private String profession;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getStuNum() {
return stuNum;
}
public void setStuNum(int stuNum) {
this.stuNum = stuNum;
}
public String getBirthday() {
return birthday;
}
public void setBirthday(String birthday) {
this.birthday = birthday;
}
public String getProfession() {
return profession;
}
public void setProfession(String profession) {
this.profession = profession;
}
}
我在main中声明了2个学生,截图如下:
该方法主要提供了,问题中所需要的具体参数和必要的set,get方法,已经重构tostring和构造方法,防止远程调用增加了序列化数据。
整体其实没有什么难度,希望楼主多看看书,学习阶段不要老copy代码,对你没好处。
创建实体类主要是参数的命名合理,类型合理以及提供一些必要的方法。
Java定义一个Student类,包括学号、姓名、性别、班级、出生日期
public class Student { private String sno; \/\/学号 private String name; \/\/姓名 private String sex; \/\/性别 private String calss; \/\/班级 private String major; \/\/专业 public String getSno() { return sno;} public void setSno(String sno) { this.sno = sno;} public String getNam...
用java定义一个学生类,要处理的信息有学号、姓名、年龄、专业。
\/\/ 一个简单的学生类 public class Student { private int sno; \/\/ 学号 private String sname; \/\/ 姓名 private int sage; \/\/ 年龄 private String profession; \/\/ 专业 public Student() { } public Student(int sno, String sname, int sage, String profession) { super();this.sno = ...
怎样用JAVA设计学生类Student,包含“学号、班级、姓名、年龄、成员...
这个很简单呀,要自己试着去写。\\r\\npublic class Students {\\r\\n\\tprivate String ID; \/\/学号\\r\\n private String classId; \/\/班级\\r\\n private String name; \/\/姓名\\r\\n\\tprivate int age; \/\/年龄\\r\\n public Students(String ID,String classId,String name,in...
用JAVA定义一个学生类Student来表示学生信息,学生类中包含成员有学号...
public class Student {private int sNo; \/\/学号private String name; \/\/姓名private String sex; \/\/性别private int yu; \/\/语文private int shu; \/\/数学private int wai; \/\/外语public int getsNo() {return sNo;}public void setsNo(int sNo) {this.sNo = sNo;}public String ge...
java编写程序 实现定义学生信息类,包括学生的姓名、学号
1 学生类 class Student{ private String name;private String number;private int score;\/\/get\/set省 public Student(){ } public Student(String name, String number, int score){ this.name=name;this.number=number;this.score=score;} } ...
JAVA编程 定义一个学生类,数据成员包括:学号,姓名,年龄,成绩;成员函数...
public class test2 { public static void main(String[] args) { Scanner sc = new Scanner(System.in);System.out.println("请输入学生个数:");int n = sc.nextInt();Student [] ss = new Student[n];for(int i=0;i<n;i++){ Scanner sca = new Scanner(System.in);Student s ...
用java写程序,定义一个student类,包含成员变量有学号、姓名、性别、班...
public class Student {\\x0d\\x0a\\x0d\\x0a\/**\\x0d\\x0a * @param args\\x0d\\x0a *\/\\x0d\\x0aboolean master; \/\/定义成员变量\\x0d\\x0aint num;\\x0d\\x0aString name,sex;\\x0d\\x0adouble math,chinese,english,score=0.0,average=0.0;\\x0d\\x0a\\x0d\\x0aStudent(int...
Java 定义一个Student类,包含内容如下: 成员变量——学号,姓名,性别,班...
import java.util.Scanner;public class Student { public static void main(String[] args) { Student student = new Student(); student.input(); float sum = student.sum(); float avg = student.avg(); System.out.println("The "+student.getName()+"'s"+" sum is...
用JAVA编写一个学生类Student的程序
学生类:public class Student { private String num;\/\/学号 private String name;\/\/姓名 private String sex;\/\/性别 private int age;\/\/年龄 public Student(String num,String name,String sex,int age){ this.num = num;this.name = name;this.sex = sex;this.age = age;} public String ...
java定义一个学生类要求学号,姓名,年龄,三个成员变量
class Student{private int STU_NUM;private String STU_NAME;private int STU_AGE;public Student(int NUM,String NAME){this.STU_NAME=NAME;this.STU_NUM=NUM;}public Student(int NUM,String NAME,int AGE){this.STU_NAME=NAME;this.STU_NUM=NUM;this.STU_AGE=AGE;}} ...