quick question. I have infact created the method of which contains an array of ten random numbers, here:
public int[] numberArray() {
Random rand = new Random();
int[] nums = new int[10];
for(int i = 0; i < nums.length; i++) {
nums[i] = rand.nextInt(100) + 1;
System.out.println(nums[i]);
}
return null;
}
This is all great, although the result of this is that when i run, the array does it correct, but at the bottom it says "Null" I know this is because of myreturn null; statement. How do i get it to not say null and just return? If i were to return the method title, it'd just loop the method, i dont want this, putting an int variable with the value "0" also just outputs 0, i dont want this.
Thank you for reading this.
P.S There's also something VERY big that i need help with within this method too, and this is that i want no numbers to be the same. When i run this, i get the same random a few times, i only want the one number once.
Aucun commentaire:
Enregistrer un commentaire