1. Check the class file byte code command by javap content
Write a simple 1.1 Test class:
public static void main(String[] args) {
int a = 2;
int b = 5;
int c = b ‐ a;
System.out.println(c);
}
After the class the next target directory will generate 1.2 to run a class file
1.3 into the target directory to start cmd command window
1.4 bytecode view the contents of the class file by command javap
1.5 View content generated javapTest.txt file is as follows
2.1 Method descriptor
Example:
The method descriptor for the method:
Object m(int i, double d, Thread t) {...}
is
(IDLjava/lang/Thread;)Ljava/lang/Object;
Method bytecode interpretation 2.2
2.3 illustrates
2.5 Different i ++ and ++ i in
2.5.1 write code
public static void main(String[] args) { new Test01().method1(); new Test01().method2(); } public void method1(){ int i=1; int a=i++; System.out.println(a); } public void method2(){ int i=1; int a=++i; System.out.println(a); }
2.5.2 After running the class target will generate class class class and find this directory
2.5.3 Input cmd from the command line in FIG open directory window and enter the command
2.5.4 View Test01.txt content
2.5.6 Comparison
i++:
++i:
the difference:
i++
Only in a local variable of the figure is the sum, not pushing data into the operand stack
The number 1 in front get, get again from the stack operation, is pressed into the local variables
++i
The digital local variables did added, and pushing data into the operand stack
The operation of the data stack, again pressed into local variables
3. string concatenation
public static void main(String[] args) { new Test02().m1(); new Test02().m2(); } public void m1(){ String s1 = "123"; String s2 = "456"; String s3 = s1 + s2; System.out.println(s3); } public void m2(){ String s1 = "123"; String s2 = "456"; StringBuilder sb = new StringBuilder(); sb.append(s1); sb.append(s2); String s3 = sb.toString(); System.out.println(s3); }
After generating the target class file generated after running 3.2 class bytecode files command (which is abbreviated as detailed in the above step operation)