Yeah, that would be what you're after.
Also consider replacing the while loop with a for loop, it's more convenient than storing a counter variable yourself.
Of course it will function exactly the same as your while, but it's ultimately down to your preference I suppose.
Regarding your program specification, int[] nums = new int[1000];
is a waste of memory, as you only need to store 100 not 1000 Integers.
(int)(1+(Math.random()*1000));
Deals with doubles, and you're obviously casting it into an int.
I'd personally recommend using nextInt(int n) method from the Random class for generating random numbers, but again, its up to you
.
Have a go implementing what you suggested, and come back if you get stuck again.
Random (Java 2 Platform SE v1.4.2)