0

Below is the starter code that my school gave me, and the error keeps persisting until I delete the reverse(int[], originalArray,) method. Can anyone tell me what is wrong here? (There's a test class given to us, but it's too long to post)

import java.util.*;
public class ReverseRecurse {

  public int[] initArray() {

  }

  public void printArray ( int[] array) {

  }

  public void reverse ( int [] originalArray, int low, int high) {

  }

  public int reverse ( int[] originalArray, ) {
  }

}
OldProgrammer
  • 12,050
  • 4
  • 24
  • 45
okbuthow
  • 59
  • 9

2 Answers2

0

There is a , after originalArray parameter also the function should return an array. If you have no array to return, then return null;

try this

public int reverse ( int[] originalArray ) { return null; }

Full code :

import java.util.*;
public class ReverseRecurse {

  public int[] initArray() {

  }

  public void printArray ( int[] array) {

  }

  public void reverse ( int [] originalArray, int low, int high) {

  }

  public int reverse ( int[] originalArray ) {
    return null;
  }

}

To implement the actual reverse function - Learn from this : How do I reverse an int array in Java?

Community
  • 1
  • 1
raj
  • 3,769
  • 4
  • 25
  • 43
0

Well for starters the

public int[] initArray() {

}

needs to have a return that would throw an error in itself.

it should be something like

public int[] initArray() {
    return someArray;
}