16-Chapter03-Example01
文章目录
- 文章介绍
- 1、完善项目结构
- 1.1 新建Chapter03模块
- 1.2 新建包和类
- 2、Demo3_1
- Student
- Example01
文章介绍
1、完善项目结构
1.1 新建Chapter03模块
1.2 新建包和类
2、Demo3_1
Student
package Demo3_1;public class Student {// 1、属性String name;// 2、方法void read() {System.out.println("大家好,我是" + name);}
}
Example01
package Demo3_1;public class Example01 {public static void main(String[] args) {Student stu1 = new Student(); // 创建第一个Student对象Student stu2 = new Student(); // 创建第二个Student对象stu1.name = "小明";stu1.read(); // 调用方法,输出小明stu2.name = "李华";stu2.read(); // 调用方法,输出李华}
}