This article brings you a detailed explanation of using javap to analyze Java string operations. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
Let’s look at this line of Java code for a simple string assignment operation.
String a = "i042416";
Use the command line to decompile the Java class containing this line of code to view its bytecode:
javap -v constant.ConstantFolding
We see that the string "i042416" was added to the constant pool by the Java compiler.
String aa1 = "i042416"; String aa2 = "jerrywang"; String aa3 = "i042416" + "jerrywang";
## Therefore, the variables aa1 and aa3 actually point to the constant pool The same constant in , so direct comparison with == will also return true.
String aa1 = "i042416jerrywang"; String aa2 = "jerrywang"; String aa3 = "i042416" + "jerrywang"; System.out.println(aa1 == aa3);
The above is the detailed content of Detailed explanation of using javap to analyze Java string operations. For more information, please follow other related articles on the PHP Chinese website!