I have an array of n elements and these methods:
last()
return the last int of the arrayfirst()
return the first int of the arraysize()
return the length of the arrayreplaceFirst(num)
that add the int at the beginning and returns its positionremove(pos)
that delete the int at the pos
I have to create a new method that gives me the array at the reverse order. I need to use those method. Now, I can't understand why my method doesn't work. so for (int i = 1; i
The remove will remove the element at the position i, and return the number that it is in that position, and then with replaceFirst will move the number (returned by remove) of the array.
I made a try with a simple array with {2,4,6,8,10,12} My output is: 12 12 12 8 6 10
so if I have an array with 1,2,3,4,5
- for i = 1; I'm gonna have : 2,1,3,4,5
- for i=2 >3,2,1,4,5
- etc
But it doesn't seem to work.