I want to generate 9 non zero random numbers whose sum is 250. I have tried following code it gives me 9 random numbers but some numbers are zero.
public vo
A call to Random.nextInt(n) will return an integer between 0 and n-1
Random.nextInt(n)
try temp = r.nextInt(250 - sum) + 1; and see if that solves your issue.
temp = r.nextInt(250 - sum) + 1;