I want to put WaterUnit, LandUnit and AirUnit in a Array and if the
generated number of the array is 1-3 its a WaterUnit and if the
generated number is 4-6 its a LandUnit and if the generated number is
7-9 its a AirUnit.
Your end result really has nothing to do with an array -- you just want to generate a random number between 1 and 9 (inclusive) and then, if that number is <= 3, return one type of object, otherwise if it is <= 6, return another type, et cetera.
In pseudo-code, that might look like this:
public function getRandom() : Unit {
value = Math.RandomNumberBetween(1,9);
if(value <= 3 ) {
return new WaterUnit();
} else if(value <= 6) {
return new LandUnit();
} else {
return new AirUnit();
}
}