Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

Students also viewed these Databases questions