Java, recursively reverse an array

后端 未结 13 1016
悲&欢浪女
悲&欢浪女 2020-12-17 16:44

I haven\'t found anything with the specific needs of my function to do this, yes, it is for homework.

So I have:

public void reverseArray(int[] x) {
         


        
相关标签:
13条回答
  • 2020-12-17 17:43

    If I were coding this, I would create a temporary array (maybe with one element removed?) for the recursive call and copy elements back into the original array before returning from the function. You will also need to find a base case to terminate the recursion.

    0 讨论(0)
提交回复
热议问题