Use the Object class

Description class java.lang.Object

  • Object class is the root class for all classes java
  • Object class declares only an empty argument constructor
  • Method Object class are: equals () toString () hashCode () wait () notify () notifyAll () clone () getClass () fianlize ()

Description equals () methods:

  • Only applies to reference data types
  • This defines the class Object equals () == method and the same effects, the value of the address compare two objects are the same,
  • Like String, Date, File, wrapper classes are rewriting the equals () method, it no longer compares address values, but to compare the contents are the same entity
  • If the use of a custom class equals () method, it is usually rewritten way to make the comparison content entity
  • == basic data types can be compared and the reference data type
  • == comparison reference data when the type of reference data required to be the same type

Description toString () method:

  • Our output when an object is referenced, the output is usually toString () method of the object
  • Like String, Date, File, wrapper classes are rewriting the toString () method, the output of the information content of the entity

 

 

Guess you like

Origin www.cnblogs.com/zhangchp/p/12441024.html