diff options
Diffstat (limited to 'tutorial/tutorial3.html')
-rw-r--r-- | tutorial/tutorial3.html | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/tutorial/tutorial3.html b/tutorial/tutorial3.html index f19e5c0d..657e629b 100644 --- a/tutorial/tutorial3.html +++ b/tutorial/tutorial3.html @@ -124,10 +124,10 @@ The following methods are part of the methods declared in Move to the first instruction.<br> <li><code>void move(int index)</code><br> Move to the instruction specified by the given index.<br> -<li><code>hasNext()</code><br> +<li><code>boolean hasNext()</code><br> Returns true if there is more instructions.<br> -<li><code>next()</code><br> -Returns the index of the next instruction. +<li><code>int next()</code><br> +Returns the index of the next instruction.<br> <em>Note that it does not return the opcode of the next instruction.</em><br> <li><code>int byteAt(int index)</code><br> @@ -141,6 +141,18 @@ Inserts a byte array at the index. Branch offsets etc. are automatically adjusted.<br> </ul> +<p>The following code snippet displays all the instructions included +in a method body: + +<ul><pre> +CodeIterator ci = ... ; +while (ci.hasNext()) { + int index = ci.next(); + int op = ci.byteAt(index); + System.out.println(Mnemonic.OPCODE[op]); +} +</pre></ul> + <p><br> <a name="bytecode"> |