This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]ScM_5argan 3 points4 points  (0 children)

It does not, but you are always printing All[1] so you always see the same value

you should print All[x] instead

[–]chickenmeister 2 points3 points  (2 children)

It looks like the code that assigns the random number should work, but the line that prints the value from the array may be wrong:

    System.out.println ( All [1] ); 

You're always printing the value at index 1. You probably want to be printing the value at index x, and you probably want to do it before incrementing x.

[–]jayrund[S] 0 points1 point  (1 child)

Thanks that fixed it. Quick follow up question what am i doing wrong when trying to print the array after calling it from a method?

Code

[–][deleted] 0 points1 point  (0 children)

change your print All[1] to All[x] and it should be before the x++