美文网首页
public class Cat

public class Cat

作者: 哈迪斯Java | 来源:发表于2023-06-19 12:33 被阅读0次

public class Cat {
String color;

public Cat(String color) {
    this.color = color;
}

public void catchMice() {
    System.out.println(color + "猫去抓老鼠了……");
}

public static void main(String[] args) {
    Cat black = new Cat("黑");
    black.catchMice();
    Cat white = new Cat("白");
    white.catchMice();
    Cat yellow = new Cat("黄");
    yellow.catchMice();
}

}

相关文章

网友评论

      本文标题:public class Cat

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