I have the following code:
public static void f(){
double i = 0.0;
for(i = 0.0; i<100.0; i++){}
}
which translates to the following bytecode:
public static void f();
Code:
0: dconst_0
1: dstore_0
2: dconst_0
3: dstore_0
4: dload_0
5: ldc2_w #2 // double 100.0d
8: dcmpg
9: ifge 19
12: dload_0
13: dconst_1
14: dadd
15: dstore_0
16: goto 4
19: return
I'm confused about the line containing the comment //double 100.0d
I sort of understand what ldc2_w
does. It grabs the appropriate constant from the constant pool. And the constant pool contains a list of defined constants after parsing the Java code, right?
But what is the purpose of #2
? How would one know what number should go here? On an online tutorial I saw someone use #4
instead?
What does this operand mean?