建立一个名叫Cat的类

    //属性 成员变量
    String name;
    int age;
    String color;
        
    //方法  函数 成员函数
    void name()
    {
        System.out.println("名字为"+name);
    }
    
    void showAge()
    {
        System.out.println("年龄为"+age);
    }
    void jiao()
    {
        System.out.println("喵");
    }
    void yanse()
    {
        System.out.println(color);
    }
原文地址:https://www.cnblogs.com/zs6666/p/5883323.html