title: Java - How to return Int[] from class method
body: <p>I have a problem, in the test of my program that I have to do as homework , theres write <code>List3 MyClass = List2.reverse()</code> List2 is a list as an array , I want to create a new list (List3) using my class (MyClass) as the List2 reversed, I did the reverse but in my method if I write <code>Public MyClass reverse() :</code>I cannot return a list , he says to me that I have to put <code>Public int[] reverse()</code> for return list but if I do in the Tester says that <code>List3 MyClass = List2.reverse()</code> cannot work because the class called is int[] type and not Class type.</p>
  
  <pre><code>public MyList reverse_new()
  {
      int[] l = new int[t.length];
      int lunghezzo = t.length - 1;
      for(int x = 0 ; x &lt; t.length ; x++)
      {
          l[x] = t[lunghezzo - x];
      }
  
  
      return l;
  }
  </code></pre>
  
  <p>here he says that I have to put int [] for return a list so then I do :</p>
  
  <pre><code>public int[] reverse_new()
  {
      int[] l = new int[t.length];
      int lunghezzo = t.length - 1;
      for(int x = 0 ; x &lt; t.length ; x++)
      {
          l[x] = t[lunghezzo - x];
      }
  
  
      return l;
  }
  </code></pre>
  
  <p>but the tester says that theres an error when I do :</p>
  
  <pre><code>public class TestList {
  public static void main(String[] args) {
  
      int[] numeri = {
              100, 200, 300
      };
  
      MyList L1 = new MyList();
      MyList L2 = new MyList(numeri);
      MyList L3 = L2.reverse_new();
  </code></pre>
  
  <p>P.S. I cannot change the Tester is from my teacher. and I can use only method created by myself.</p>