What is the execute sequence of i++ in java -
what execute sequence of following code?
if (hash[s.charat(right++)]-- >= 1) in understanding
1. hash[s.charat(right)] >= 1 2. hash[s.charat(right)]-- 3. right++; thank you!!!!
execute sequence of if (hash[s.charat(right++)]-- >= 1) is:
- read value of
hash(a) - read value of
s(b) - read value of
right(c) - increment value of
right - call
b.charat(c)(d) - read value of
a[d](e) - decrement value of
a[d] - read constant
1(f) - skip past
ifblock ife < f.
if hash, s, , right 3 local variables, bytecode of if statement is:
1: aload_1 2: aload_2 3: iload_3 4: iinc 3, 1 5: invokevirtual #21 // method java/lang/string.charat:(i)c 6: dup2 iaload 7: dup_x2 iconst_1 isub iastore 8: iconst_1 9: if_icmplt 99 update
the effect same as-if had written:
boolean cond = hash[s.charat(right)]; hash[s.charat(right)]--; right++; if (cond) { except values read once, , charat() call , index lookup happens once.
Comments
Post a Comment