-
Comparison of equality:
1. For native data types, the comparison is between the left and right sides of the value is equal
2. For reference types, compare whether the left and right references point to the same object, or whether the reference addresses are the same on both sides
-
Java.lang.Object class. The Java.lang package does not need to display the import when it is used, and the compiler automatically helps us to import it at compile time
-
API (Application Programming Interface), application programming interface.
Package Com.yuanzijian01;public class Objecttest {public static void main (string[] args) {//TODO auto-generated method Stub Object object = New Object (); System.out.println (object);}}
Execution results
[Email protected]//printed results are different every time
Note: When you print a reference, you actually print the return value of the ToString () method that refers to the object being referenced, because each class inherits directly or indirectly from object, and ToString () is defined in the object class because each class has the ToString () method,
Package Com.yuanzijian01;class Student extends Object{public String toString () {return "Hello word";}} public class Objecttest {public static void main (string[] args) {//TODO auto-generated method Stub Object object = new Object (); System.out.println (object); System.out.println (Object.ToString ()); String str = "ABC"; System.out.println (str); System.out.println (Str.tostring ()); Student stu = new Student (); System.out.println (Stu); System.out.println (Stu.tostring ());}}
Execution results
[Email protected] [Email Protected]abcabchello Wordhello Word
Description of the object class in Java