java == 和equals()

equals()

First we enter the root class equals method can be seen is the root of the parent class

equals () method is carried by the Object class because all classes are directly or indirectly Object class inherits all classes have so equals () 
  a: is not a method of operator
  II: reference data types only applicable to
  three : Object class defines
  public Boolean the equals (Object obj) {
      return (the this == obj);
  }
  described in Object equals () == and determines whether two objects are the same memory address value with a

four: String Date , File, wrapper class overrides equals the root of the parent class () method, after rewriting the comparison is not a reference address is the same, but the "real content" to compare two objects are the same

 

Guess you like

Origin www.cnblogs.com/zhaoyunlong/p/11547414.html