public class Cow { private double weight; public Cow(){}; public Cow(double weight) { this.weight=weight; } private class CowLeg { private double length; private String color; public CowLeg(){}; public CowLeg(double length,String color) { this.color=color; this.length=length; } public void setLength(double length) { this.length=length; } public double getLength() { return this.length; } public void setColor(String color) { this.color=color; } public String getColor() { return this.color; } public void info() { System.out.println("牛腿颜色:"+color+" 高:"+length); System.out.println("本牛腿所在奶牛重:"+weight); } } public void test() { CowLeg cl=new CowLeg(1.12,"黑白相间"); cl.info(); } public static void main(String[] args) { Cow cow=new Cow(378.9); cow.test(); } }