这篇文章之所以叫猫和猫的名字,是因为是以猫为案例来讲的
主要的内容就是java构造函数和参数的传递
class Animal { public static String name; Animal(String name) { this.name=name ; } public void enjoy() { System.out.println("动物的叫声……"); } } class Cat extends Animal { public String eyesColor; public String name; Cat(String catname, String c) { super(catname); eyesColor = c; this.setName(catname); } public void setName(String name){ this.name = name; } public String getName() { return name; } public void enjoy() { System.out.println("我养的猫高兴地叫了一声……"); } } public class lianxi { public static void main(String args[]) { Cat c = new Cat("caty", "blue"); c.enjoy(); System.out.println(c.name); System.out.println(Animal.name); } }