java第六天

 p37

1、java ant详解

练习8

/**
 * Created by xkfx on 2017/2/26.
 */
class A {
    static int i = 47;
}
public class TestStatic {
    public static void main(String[] args) {
        A a1 = new A();
        A a2 = new A();
        A a3 = new A();
        a2.i++;
        a3.i++;
        System.out.println(a1.i);   // 并没有直接通过a1来改变i
    }
}

练习9

/**
 * Created by xkfx on 2017/2/26.
 */
public class Test {
    public static void main(String[] args) {
        Boolean b = true;
        boolean b1 = b;
        System.out.println(b1);

        Character ch = 'x';
        char c = ch;
        System.out.println(c);

        Byte by = 1;
        byte b2 = by;
        System.out.println(b2);

        Integer in = 1;
        int k = in;
        System.out.println(k);
    }
}

不用写全部吧。。。

练习10

/**
 * Created by xkfx on 2017/2/26.
 */
public class Test {
    public static void main(String[] args) {
        for (int i = 0; i < args.length; ++i) {
            System.out.println(args[i]);
        }
    }
}

测试示例:

mdzz@LAPTOP-QGECNCGO MINGW64 /d/Projects/untitled/src
$ java Test 1 2 Hello
1
2
Hello

练习11

/**
 * Created by xkfx on 2017/2/26.
 */
public class ALLTheColorsOfTheRainbow {
    int anIntegerRepresentingColors;
    void changeTheHueofTheColor(int newHue) {
        this.anIntegerRepresentingColors = newHue;
    }
    public static void main(String[] args) {
        ALLTheColorsOfTheRainbow x = new ALLTheColorsOfTheRainbow();
        x.changeTheHueofTheColor(17);
        System.out.println(x.anIntegerRepresentingColors);
    }
}
原文地址:https://www.cnblogs.com/xkxf/p/6446049.html