Java,定义类

package wanzai;
//鸟类
public class Bird {
    //属性 成员变量
    
    //颜色
    String Color;
    
    //重量
    double Weight;
    
    //行为 方法
    
    //飞 void-没有返回值
    void fly()
    {
        System.out.println("我能飞");
    }
    
    //
    void eat()
    {
        System.out.println("我喜欢吃虫子");
    }

    public static void main(String[] args) {
        //生成一只鸟的实例老鹰
        Bird eagle=new Bird();
        eagle.Color="灰色";
        eagle.Weight=10;
        System.out.println("这只鸟的颜色是"+eagle.Color);
        eagle.fly();
        eagle.eat();
        
        
        

    }

}

posted @ 2016-03-02 16:19  什么玩楞啊,我叫旺仔  阅读(297)  评论(0编辑  收藏  举报