Reputation: 57
I am writing a code for an assignment, and I want to know what this means.
The int's in the array should be initialized so that all int's at indexes of the form 0 mod 4 are - 1
What is this saying? How do I initialize a certain value at an index?
Upvotes: 0
Views: 53
Reputation: 1003
Am I getting you right, that you need to initialize elements with -1
where index modulus by equals 0
int[] arr = {1,2,3,4,5,6,7,8};
for (int i=0;i<arr.length;i+=4) arr[i]=-1
Upvotes: 1