JPad
Snippets
Download
Help
Contact
Generating Random Int Array Within Range
Code
Random rand = new Random(); int[] r = new int[9]; for(int i=0; i<r.length; i++) { r[i] = rand.nextInt(99); } Dump(r);
Result
Console
int[] {55,25,36,51,59,87,54,38,12}
Bytecode
Compiled from "RunnContainer.java" public class io.jpad.scratch.RunnContainer { public io.jpad.scratch.RunnContainer(); Code: 0: aload_0 1: invokespecial #1 // Method java/lang/Object."<init>":()V 4: return public static void main(java.lang.String...) throws java.lang.Exception; Code: 0: new #2 // class java/util/Random 3: dup 4: invokespecial #3 // Method java/util/Random."<init>":()V 7: astore_1 8: bipush 9 10: newarray int 12: astore_2 13: iconst_0 14: istore_3 15: iload_3 16: aload_2 17: arraylength 18: if_icmpge 36 21: aload_2 22: iload_3 23: aload_1 24: bipush 99 26: invokevirtual #4 // Method java/util/Random.nextInt:(I)I 29: iastore 30: iinc 3, 1 33: goto 15 36: aload_2 37: invokestatic #5 // Method io/jpad/scratch/Dumper.Dump:(Ljava/lang/Object;)Ljava/lang/Object; 40: pop 41: return }
Jpad Version:1.05
viewCount:5181
Creator:
admin
Latest Editor:
admin
Tags
random
Download
Copy As Markdown:
**code [Generating Random Int Array Within Range.java](/example/1s/generating-random-int-array-within-range)** Random rand = new Random(); int[] r = new int[9]; for(int i=0; i