p41~p45:

1、区别前缀式后缀式

public class Test {
    public static void main(String[] args) {
        int i = 1;
        System.out.println("i : " + i);
        System.out.println("++i : " + ++i);
        System.out.println("i : " + i);
        System.out.println("i++ : " + i++);
        System.out.println("i : " + i);
    }
}
i : 1
++i : 2
i : 2
i++ : 2
i : 3

 

2、在java中,等于和不等于适用于所有的基本数据类型,也使用于所有对象

 

3、==、!=比较的是对象的引用

 

4、在没有重载equals()方法之前,equals的默认行为是比较引用。(equals方法默认继承自object类)

 

练习4

public class Test {
    public static void main(String[] args) {
        final float s = 97;
        final float t = 20;
        float v = s / t;
        System.out.println(v);
    }
}

 

练习5

public class Dog {
    private String name;
    private String says;
    public Dog(String name, String says) {
        this.name = name;
        this.says = says;
    }
    public String toString() {
        return this.name + ":" + this.says;
    }
    public static void main(String[] args) {
        Dog d1 = new Dog("spot", "Ruff!");
        Dog d2 = new Dog("scruffy", "Wurf!");
        System.out.println(d1);
        System.out.println(d2);
    }
}