Hello.import java.util.Scanner; public class test11{ public static void main( String[] args ) { int[] RandomValue = new int[100];//creating 100 random numbers for ( int r=0; r<RandomValue.length; r++){ RandomValue[r] = (int)(Math.random()*9 + 1 );}//the range of random number is from1-100 int n=0; System.out.println(RandomValue[n] +" > "+RandomValue[n+1]+" > "+RandomValue[n+2]); } }
Basically I want RandomValue[n+1] to replace n when I press enter and so on.
for example:
1 > 4 > 3
(press enter)
4 > 3 > 6
(press enter)
(looping...)
(6 is the new random value(RandomValue[n+3]) and 4(RandomValue[n+1]) replaced 1(RandomValue[n]) and 3(RandomValue[n+2]) replaced 4(RandomValue[n+1])
I've tried using for loop and while loop but the result was not I expected
Could someone please help?Thanks.