Working with elements of an array

  • 6
  • Locked
Implement the main(String[]) method so that it reverses the sign of an element of the array if the element is even.
You can't complete this task, because you're not signed in.
Comments (1)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Chrizzly
Level 12 , Earth, Germany
12 August 2022, 14:39
Even if the concept is easy to understand, this exercise was not too easy, without having seen the syntax before. Isn't there any better way, to go through the indices? Maybe something like
array[i] = array[i] * (-1);
? Of course this won't work 1:1, but you understood my thought here.