1)当==两边是对象时(String,Integer...),两边比的都是地址2)当==两边是基本类型时(int,float),两边比的都是值3)默认equals比的是对象的地址,但是重写的话可以改变成比较值,String和Integer的equals就是重写过的 废话少说,Run!!! package test; public class Test { public static void main(String[] args) { System.out.println("##########…
前言 最近在读<Thinking in Java>,看到这样一段话: Primitives that are fields in a class are automatically initialized to zero, as noted in the Everything Is an Object chapter. But the object references are initialized to null, and if you try to call methods for an…