I'm generating a random number every 10 second; In arraylist I'mStoring and Updating the number every 10 second when I generate newnumber. However, my goal to call the update number from arraylistin another class main method. I would apperciate any help.
//this is the class I'm generating a random number every 10second and Storing and Updating the number in arraylist.
package com.singltondesignpattern;
import java.util.ArrayList;
import java.util.Random;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
public class EverySecond {
public static int genrand() {
Random number =new Random();
int rand=number.nextInt(1000);
return rand;
}
public static void getrand(int rand) { Â Â
ArrayList randomstorage = newArrayList();
randomstorage.add(rand);
System.out.println(\"Array value \"+randomstorage);
}
public static void main(String[] args) throws Exception {
Runnable helloRunnable = new Runnable() {
public void run() {
int CurrentNum=genrand(); //create a random number
System.out.println(\"generate number ==== \"+CurrentNum);
getrand(CurrentNum); //update it in array list
}
};
ScheduledExecutorService executor =Executors.newScheduledThreadPool(1);
executor.scheduleAtFixedRate(helloRunnable, 0, 10,TimeUnit.SECONDS);
  }
}
//this is the class I want to get the update number from thearraylist
public class getTheUpdate {
public static void main(String[] args) throws Exception {
EverySecond everySecond = new EverySecond();
everySecond.getrand(0);
}
}