类Student的成员变量: sNO 表示学号;sName表示姓名;sSex表示性别;sAge表示年龄;sJava:表示Java课程成绩。
时间: 2024-05-13 07:18:46 浏览: 284
下面是示例代码:
```
public class Student {
private String sNO; // 学号
private String sName; // 姓名
private String sSex; // 性别
private int sAge; // 年龄
private double sJava; // Java课程成绩
// 构造方法
public Student(String sNO, String sName, String sSex, int sAge, double sJava) {
this.sNO = sNO;
this.sName = sName;
this.sSex = sSex;
this.sAge = sAge;
this.sJava = sJava;
}
// getter和setter方法
public String getNO() {
return sNO;
}
public void setNO(String sNO) {
this.sNO = sNO;
}
public String getName() {
return sName;
}
public void setName(String sName) {
this.sName = sName;
}
public String getSex() {
return sSex;
}
public void setSex(String sSex) {
this.sSex = sSex;
}
public int getAge() {
return sAge;
}
public void setAge(int sAge) {
this.sAge = sAge;
}
public double getJava() {
return sJava;
}
public void setJava(double sJava) {
this.sJava = sJava;
}
}
```
以上代码中,我们定义了类`Student`,并在其中定义了五个成员变量`sNO`、`sName`、`sSex`、`sAge`、`sJava`,分别表示学号、姓名、性别、年龄、Java课程成绩。在构造方法中,我们对这些成员变量进行了初始化;并且提供了 getter 和 setter 方法,以便在程序中可以获取和修改这些成员变量的值。
阅读全文
相关推荐
![java](https://img-home.csdnimg.cn/images/20250102104920.png)
![text/x-c++](https://img-home.csdnimg.cn/images/20250102104920.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![java](https://img-home.csdnimg.cn/images/20250102104920.png)