Decompile view the printf () method

Source:

 1 package test2;
 2 
 3 public class ExplorationJDKSource {
 4 
 5     /**
 6      * @param args
 7      */
 8     public static void main(String[] args) {
 9         System.out.println(new A());
10     }
11 
12 }
13 
14 class A{}

Output:

test2.A@15db9742

Decompile results are as follows:

 

 

Analysis :( Mandarin)

The previous example, main method actually calls:

void println public (the X-Object) , this method internally calls the valueOf method of the String class.

valueOf internal method in turn calls Object.toString method:

public String toString() {

return getClass().getName() +"@" +

Integer.toHexString(hashCode());

}

hashCode method is a local method, implemented by the JVM designer:

public  native int hashCode();

Call the parent's method.

Guess you like

Origin www.cnblogs.com/cxy0210/p/11728488.html