编写一个表示学生的Java类Student。

供稿:hz-xin.com     日期:2025-01-14
java定义一个表示学生信息的类

public class Student { /* * (non-Javadoc) * * @see java.lang.Object#toString() */ @Override public String toString() { return "StudentInfo
[No=" + sNo + ", Name=" + sName + ", Sex=" + sSex + ", Age=" + sAge + ", Java=" + sJava + "]"; } /** * @param sJava * the sJava to set */ public void setsJava(int sJava) { this.sJava = sJava; } /** * @param sNo * @param sName * @param sSex * @param sAge * @param sJava */ public Student(String sNo, String sName, String sSex, int sAge, int sJava) { super(); this.sNo = sNo; this.sName = sName; this.sSex = sSex; this.sAge = sAge; this.sJava = sJava; } /** * @return the sNo */ public String getsNo() { return sNo; } /** * @return the sName */ public String getsName() { return sName; } /** * @return the sSex */ public String getsSex() { return sSex; } /** * @return the sAge */ public int getsAge() { return sAge; } /** * @return the sJava */ public int getsJava() { return sJava; } private String sNo; private String sName; private String sSex; private int sAge; private int sJava;}public class TestStudent { public static void getAverage(float java[]) { int n = 0; float sum = 0; while (n max) { max = java[n]; } if (java[n] < min) { min = java[n]; } } System.out.println("Max = " + max + ";Min = " + min); } public static void printInfo(String s[]) { for (String a : s) { System.out.println(a); } }; public static void main(String[] args) { Student s1 = new Student("s1", "Zhao", "male", 16, 11); Student s2 = new Student("s2", "Qian", "female", 16, 10); Student s3 = new Student("s3", "Sun", "male", 16, 30); Student s4 = new Student("s4", "Li", "female", 16, 40); Student s5 = new Student("s5", "Zhou", "male", 16, 50); String[] sInfo = { s1.toString(), s2.toString(), s3.toString(), s4.toString(), s5.toString() }; float[] iJava = { s1.getsJava(), s2.getsJava(), s3.getsJava(), s4.getsJava(), s5.getsJava() }; printInfo(sInfo); getAverage(iJava); getMaxMin(iJava); }}

public class Student{ private String num; private String sex; private String name; private int age; public Student(String num,String sex,String name){ this.num=num; this.sex=sex; this.name=name; } public String getNum(){ return this.num; } public String getSex(){ return this.sex; } public String getName(){ return this.name; } public int getAge(){ return this.age; } public void setAge(int age){ this.age=age; } public String toString(){ return "My name is %s, I'm %s years old. I'm a %s. My student num is %s"; }}public class Test{ public static void main(String[] args){ Student student=new Student("N01","boy","zhangsan"); student.setAge(18); System.out.priltln(String.format(student.toString(),student.getName(),student.getAge().toString(),student.getSex(),student.getNum())); }}ok啦 就是这样

package a;
public class Student{
public static void main(String args[]){
private int stuId;
private String name;
//其它属性省略,方法同上。
public Student(){
//默认构造方法
}
public void setStuId(int stuId){
this.stuId=studId;
}
public void setName(String name){
this.name=name;
}
public int getStuId(){
return this.stuId;
}
public String getName(){
return this.name;
}
public String toString(){

}
}
}
package b;
public class Teacher(){
Student stu=new Student();
}

太多了,多少方法呢?极简单又麻烦
以上回答你满意么?

编写一个表示学生的Java类Student。
Student stu=new Student();}

一道java题 请设计一个学生类Student。属性包括:学号、姓名、英语成绩...
public class Student{ private String stuId; private String name; private float englishScore; private float mathScore; private float computerScore; private float sumScore; public Student() { } public Student(String stuId, String name, float englishScore, ...

Java程序设计.在线等,求高手帮忙.
s[1] = new Student("s002", "李四", 86, 79, 90);s[2] = new Student("s003", "王五", 93, 80, 93);s[3] = new Student("s004", "赵六", 81, 87, 80);System.out.println("学生信息如下:");for (int i = 0; i < 4; i++) { System.out.println("注册号:" ...

java 写一个类Student,包含三个属性学号id,姓名name和年龄age;_百度知...
public static void main(String[] args) { Student stu1=new Student("1234", "张三", 12);Student stu2=new Student("1234");System.out.println(stu2.equals(stu1));} }

编写Java程序,定义一个学生类,并编写主类测试该类的功能。基本要求如下...
public static void main(String args[]){ boolean e=true;Student stu=new Student();Scanner sc=new Scanner(System.in);while(e){ System.out.println("\\t\\t\\t\\t\\t***欢迎进入学生信息系统***\\t\\t\\t\\t\\t");System.out.println("\\t\\t\\t\\t\\t*** 1:录入学生的信息***\\t\\t\\t...

定义一个“Student”类,包含的内容有: 成员变量:学号,姓名,性别,数学成...
chineseScore)\/2;} public static void main(String[] args) { int mathScore=50;int chineseScore=59;Student stu=new Student();System.out.println("总分为:"+stu.sum(mathScore,chineseScore));System.out.println("平均分为:"+stu.average(mathScore,chineseScore));} } 这个是java的 ...

java编写一个Student类,含姓名,学号,班级,属性私有,序列化对象_百度知 ...
你的其实就是一个普通的java bean对象,所谓序列化,其实就是把对象以流的形式进行存储和传输,说白了就是实现一个序列化的接口。import java.io.Serializable;public class Student implements Serializable { private static final long serialVersionUID = 1L;private String susername;\/\/ 姓名 private ...

Java:学生信息姓名、学号、成绩。定义一个类,并定义相关的构造函数和方...
1、代码如下:Main类 import java.util.*;import java.io.BufferedReader;import java.io.InputStreamReader;\/ Main 主方法 author bufei \/ public class Main { public static void main(String[] args) { stuGrad();} public static void stuGrad() { int stuNum = 1;Student[] stu = new...

急求JAVA!!!
import java.util.Scanner;\/\/学生类 class Student{ private int ID; \/\/学号 private String password; \/\/密码 private String name; \/\/姓名 private int age; \/\/年龄 public Student(){ } public Student(int ID,String password,String name,int age){ this.ID = ID;this.password...

JAVA按要求完成下列程序编写,学生类
给你一个相对完整的代码吧 Student类:package com.baidu.students;import java.util.List;import java.util.Scanner;public class Student implements Comparable<Student> { \/\/ 继承现有的java.lang.Comparable接口,可支持List的排序private String stuNo; \/\/ 学号private String stuName; \/\/ 姓名private...