This Java class generates 6 lottery numbers and stores them in an array.
The class ensures that no numbers are drawn twice.

[code]public class LotterynumbersArray {
public static void main(String[] args) {
// TODO Auto-generated method stub
boolean[] drawnball;
int[] lotterynumbers;
int randomnumber =0;
lotterynumbers= new int[6];
drawnball= new boolean[49];
for ( int i =0; i < lotterynumbers.length; i ++){
if (i==0){
randomnumber=(int) (Math.random()*49+1);
lotterynumbers[0]=randomnumber;
drawnball[randomnumber-1]=true;
}
randomnumber=(int) (Math.random()*49+1);
while (drawnball[randomnumber-1]==true){
randomnumber=(int) (Math.random()*49+1);
}
drawnball[randomnumber-1]=true;
lotterynumbers[i] = randomnumber;
}
for ( int i =0; i <= 5; i ++){
System.out.println("Lotterynumber " + (i+1) + " is: " + lotterynumbers[i]);
}
}
}
[/code]