Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ARRAY HELP

807600Sep 18 2007 — edited Sep 19 2007
how would you do this........write a method that repeatedly selects and removes a random entry from an array until the array holds no more entries

this is what i got
while ( count != array.length){

         int random = (int)(Math.random() * array.length ) ;
         if (array[random] != 0){
	array[random] = 0;
	count++;
         }
}
i'm assuming the array holds ints and i set the indexes to 0.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 17 2007
Added on Sep 18 2007
16 comments
494 views