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!

Resetting array values

843789Apr 28 2009 — edited Apr 28 2009
The have read the Java Tutorial on Arrays and gather that you can initialise an array as follows:
int[] secitnum = {0,0,0,0,0};
But it is not immediately clear how to reset it back to {0,0,0,0,0} after it has changed to say {5,3,0,0,0} (in the course of running a program) without looping through and resetting each element individually as follows:
for(int i=0; i<5; i++){
               secitnum[i] = 0;
          }
This seems rather longwinded. I'd like to write:
secitum = {0,0,0,0,0}
but it won't compile. Is there an expression like this which will do the job, or is looping the only option?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 26 2009
Added on Apr 28 2009
5 comments
128 views