定义一个表示学生信息的类 Student

img


public class Student {
    private String sNo;
    private String sName;
    private int sAge;

    public Student(String sNo, String sName, int sAge) {
        this.sNo = sNo;
        this.sName = sName;
        this.sAge = sAge;
    }

    public Student() {
        this.sName = "乐乐";
        this.sAge = 5;
    }

    public String getsNo() {
        return sNo;
    }

    public void setsNo(String sNo) {
        this.sNo = sNo;
    }

    public String getsName() {
        return sName;
    }

    public void setsName(String sName) {
        this.sName = sName;
    }

    public int getsAge() {
        return sAge;
    }

    public void setsAge(int sAge) {
        this.sAge = sAge;
    }

    @Override
    public String toString() {
        return "Student{" +
                "sNo='" + sNo + '\'' +
                ", sName='" + sName + '\'' +
                ", sAge='" + sAge + '\'' +
                '}';
    }

    public void info() {
        System.out.println("我的名字叫:" + getsName() + ",今年" + getsAge() + "岁了,很高兴认识你");
    }
}

public class Test {

    public static void main(String[] args){
        Student student = new Student("1", "乐乐", "男", 5);
        student.sayHello();
    }

}

class Student {
    private String sNo;
    private String sName;
    private String sSex;
    private int sAge;

    public Student(String sNo, String sName, String sSex, int sAge) {
        this.sNo = sNo;
        this.sName = sName;
        this.sSex = sSex;
        this.sAge = sAge;
    }

    public void sayHello(){
        System.out.println("我的名字叫"+sName+",今年"+sAge+"岁了,"+"很高兴认识你。");
    }
}

如有帮助建议采纳

希望回访

我想在1024发的一篇博客。_Pumpkin's Blog-CSDN博客 前言  本篇文章不谈技术,只写一些随笔。  直到今天(2021年10月24日)笔者已经毕业一年了。其实在这之前我对于1024,程序员这些名词在心里其实并不是很在意,每年在这一天大概就是看看网上的搞笑新闻以及图片,心里笑一笑就过去了。但是今年对于1024突然有一种别样的感觉,不同于往日,好像这就是我应该过的一个节日。  为什么会产生这样的感觉呢?我思索良久,大概可能是因为已经真正意义的工作了一年,内心接受了自己属于程序员的这个大群体,并且从某种意义上来说这是工作后的第一个1024,新鲜感也是一方面吧。但 https://blog.csdn.net/weixin_44235109/article/details/120924109?spm=1001.2014.3001.5502