Generate random numbers that haven't been generated before.

I'm relatively new to Java and programming, and I've come accross a problem.
I'm having a 2-dimensional array which holds an Object.

Java Code:

public DataItem[][] dataTiles = new DataItem[tileWidth][tileHeight];

The DataItem class has only two variables a x and a y value.
Each array index stands for a position in the world, so if you would have a DataItem with x = 4 and y=32 then it's place in the array would be: dataTiles[4][32].

However the problem is that there is a change that there are two data items at the same coördinates.
This is not allowed to happen, so these randX and randY variables can only be a empty place in the world.

Could anybody point me in the right direction of how to do such a thing?

Re: Generate random numbers that haven't been generated before.

Sounds like you're going to have to keep track of which coordinates you've already used, then check against it when creating a new one. Or you could go the other way around and start out with a collection of valid locations, then remove them or mark them as invalid as you place coordinates.

Re: Generate random numbers that haven't been generated before.

I think we've had something like this before, and one solution was a List<Coordinates> (in your case), and using Collections.shuffle().
Then simply iterate over the shuffled list, assigning DataItems to the coordinates.