工作需求,猛看Java,学习完了马士兵老师的第一阶段视频,做一下记录和总结。

##Hello world

HelloWorld.java

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello world !");
    }
}

##变量

byte int short long float double char boolean

##数组

int a[];
int [] a = new int[100];
int [] b = new int[] {1, 2, 3};

#类

FaceObject.java

interface dot {
    void fishing();
}
public class FaceObject {
    public static void main(String[] args) {
        Fish f = new Fish();
        f.fishing();
    }
}

class Fish implents dot{

    private int amount;

    void fishing() {
        System.out.println("Fsh is fishing");
    }
    
    int getAmount() {
        return amount;
    }

    Fish(int amount) {
        this.amount = amount;
    }

    Fish() {
        this.amount = 0;
    }
}

#END



blog comments powered by Disqus

Published

04 April 2015

Tags