摘要: public class Dog {// 定义属性 String nick; String color; int age; // 定义构造方法 public Dog(String nick,String color,int age){// 构造方法的作用是为对象的属性赋值 this.nick=nic 阅读全文
posted @ 2021-12-30 15:44 小小生Sir 阅读(12) 评论(0) 推荐(0) 编辑
摘要: // 定义属性 String nick; String color; int age;// 定义类的方法 public void eat(){ System.out.println("在吃东西"); } public void run(){ System.out.println("在跑步"); } 阅读全文
posted @ 2021-12-30 15:07 小小生Sir 阅读(22) 评论(0) 推荐(0) 编辑