-----------android培训、java培训、java学习型技术博客、期待与您交流!------------
| package com.itheima; /* 声明类Student,包含3个成员变量:name、age、score,要求可以通过 new Student("张三", 22, 95) 的方式创建对象,并可以通过set和get方法访问成员变量 */ class Student { String name; int age; int score; public Student (String name,int age,int score){ this.name=name; this.age=age; this.score=score; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public int getScore() { return score; } public void setScore(int score) { this.score = score; } } public class Test8 { public static void main(String[] args) { Student Student=new Student("张三", 22, 95); System.out.println(Student.getName()); System.out.println(Student.getScore()); System.out.println(Student.getAge()); Student.setName("李四"); Student.setAge(23); Student.setScore(99); System.out.println(Student.getName()); System.out.println(Student.getScore()); System.out.println(Student.getAge()); } } |
908

被折叠的 条评论
为什么被折叠?



