美文网首页
public class Student练习35

public class Student练习35

作者: 哈迪斯Java | 来源:发表于2023-06-15 23:24 被阅读0次

    public class Student {
    String name;
    int age;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }
    
    public String toString() {
        return "我叫" + name + ",今年" + age + "岁。";
    }
    
    public static void main(String[] args) {
        Student s1 = new Student("张三", 16);
        System.out.println(s1);
        Student s2 = new Student("李四", 19);
        System.out.println(s2);
    }
    

    }

    相关文章

      网友评论

          本文标题:public class Student练习35

          本文链接:https://www.haomeiwen.com/subject/vophddtx.html