Question
JAVA Array Question. How to increment an array by -1 in one single loop? For example: int[] arr = [1, 2, 3, 4]; for(i=0; i
JAVA Array Question.
How to increment an array by -1 in one single loop? For example:
int[] arr = [1, 2, 3, 4];
for(i=0; i //do something } and at the end of the first loop i want arr to be: arr = [0, 1, 3, 4], and then when i=2, arr= [ 0, 0, 2, 4], etc. I tried this: for(i=0; i arr--; //do something } but it gives me: arr = [0, 2, 3, 4], [0, 1, 3, 4], etc.. only one element at a time. Please help me with this data structure. Thumbs up will be given for correct answer! thank u
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started