- class TestPracticeStudent{
- public static void main(String[] args) {
- Student student = new Student();
- student.study();
- System.out.println("-------------------------");
- student.studentInformation();
- System.out.println("-------------------------");
- student.name = "王五";
- student.age = 25;
- student.sex = "女";
- student.studentInformation();
- }
- }
- class Student {
- String name;
- int age;
- String sex;
- void study(){
- name = "张三";
- System.out.println(name + "学习");
- }
- void studentInformation(){
- age = 20;
- name = "李四";
- sex = "男";
- System.out.println("姓名" + name + "\n年龄" + age + "\n性别" + sex);
- }
- }
复制代码 |
|