类里面建类
class animals{ class dog{ int leg; String name; public dog(int leg,String name){ this.leg=leg; this.name=name; } void run(){ System.out.println(name+"用"+leg+"条腿跑"); } } } public class ChengYuanClass { public static void main(String[] args) { new animals().new dog(4, "哈士奇").run(); } }
原文:https://www.cnblogs.com/LYY1084702511/p/10897474.html