вторник, 11 октября 2011 г.

Test Casual 1


public class TestClass {

    Integer num1 = null;
    Integer num2 = null;

    public TestClass(Integer num1, Integer num2) {
        this.num1 = num1;
        this.num2 = (num2 != null && num2 < 1) ? 10 : num2;
    }

    public static void main(String[] args) throws Exception {
        TestClass test1 = new TestClass(0, 0);
        System.out.println("test1=" + test1.num1 + " " + test1.num2);

        TestClass test2 = new TestClass(null, 0);
        System.out.println("test2=" + test2.num1 + " " + test2.num2);

        TestClass test3 = new TestClass(0, null);
        System.out.println("test3=" + test3.num1 + " " + test3.num2);
    }
}

Комментариев нет: