Assuming your array of numbers looks like this, initialized somewhere in your class:
int[] numbers = new int[]{ 123, 321, 456, 765, 923, 931 };
You can create a method looking like this:
private int getRandomNumberFromArray(){
int min = 0;
int max = numbers.length;
return numbers[min + (int)(Math.random() * ((max - min) + 1))];
}
Then you could call that method like this:
int randomNumberFromArray = getRandomNumberFromArray();
Look into this thread for a detailed explanation of Java's Random implementation.
As for your other problems, I'm not quite sure what you are trying to accomplish. Please provide some more details.
Update
With your OP updated, I think I have a better idea of what you're trying to do. Allow me to revise.
First, for getting images displayed with Slick2D, here is a good, short video tutorial. I recommend you check his series on the subject, as they are very clear and concise.
As for your timer, I found this piece of code here.
int time;
public void update(GameContainer container, int delta) {
time += delta;
}
public void render(GameContainer container, Graphics g) {
g.drawString("Time : " + time/1000, 100, 100);
}
This will draw a simply timer that on the screen at x=100, y=100 that updates itself. This is something you could use for test purposes. As for your random interval, you can expand on the above code like this.
int time;
int deadline; // initialize this somewhere in the start of your game
public void update(GameContainer container, int delta) {
time += delta;
}
public void render(GameContainer container, Graphics g) {
g.drawString("Time : " + time/1000, 100, 100);
// if the current time has passed the deadline, do something
if(time > deadline){
int min = 2;
int max = 3;
deadline = time + ((min + (int)(Math.random() * ((max - min) + 1))) * 1000); // reset the interval timer
// draw the image
int x = 100;
int y = getRandomNumberFromArray(); // this is the method I provided in my first part of the answer
Image img = new Image("path/file.png");
g.drawImage(img, x, y) // image file, x, y
}
}
This piece of code creates a deadline that functions as a random interval timer. The deadline is a summation of the current time, to which a number between 2 and 3 will be added (multiplied with 1000, because time is kept in milliseconds). When the current time surpasses this deadline, a random image will be created.
As for displaying multiple images, I would refer to the previously linked tutorial. I think this could be accomplished by keeping track of the images in an ArrayList. Then rendering all of those images in the render() method. But I'm not quite sure since I only know a few basics of Slick2D.
I haven't tested any of this, but I hope to have pointed you into the right direction.
Update 2
As for the recommendation in the comment, this would be a way of implementing that.
ArrayList<DrawnImage> images; // make sure you initialize this at the beginning as: images = new ArrayList<Image>();
int time;
int deadline; // initialize this somewhere in the start of your game
public void update(GameContainer container, int delta) {
time += delta;
}
public void render(GameContainer container, Graphics g) {
g.drawString("Time : " + time/1000, 100, 100);
// if the current time has passed the deadline, do something
if(time > deadline){
int min = 2;
int max = 3;
deadline = time + ((min + (int)(Math.random() * ((max - min) + 1))) * 1000); // reset the interval timer
// draw the image
int x = 100;
int y = getRandomNumberFromArray(); // this is the method I provided in my first part of the answer
images.add(new DrawnImage(new Image("path/file.png"), x, y));
for(DrawnImage di : images){
g.drawImage(di.image, di.x, di.y); // image file, x, y
}
}
}
DrawnImage class
public class DrawnImage {
public Image image;
public float x;
public float y;
public DrawnImage(Image image, float x, float y){
this.image = image;
this.x = x;
this.y = y;
}
}