title: Returning jint array from c to java through jni
body: <p>I have created an integer array in java and passed the array to a cpp programme through jni
  My Code is:</p>
  
  <pre><code>import java.util.*;
  
  class SendArray {
    //Native method declaration
    native int[] loadFile(int[] name);
    //Load the library
    static {
      System.loadLibrary("nativelib");
    }
  
    public static void main(String args[]) {
      int arr[] = {1,2,3,4,5,6,7,8,9,10};
      //Create class instance
      SendArray mappedFile=new SendArray();
      //Call native method to load SendArray.java
      int[] buf = mappedFile.loadFile(arr);
      //Print contents of SendArray.java
      for(int i=0;i&lt;buf.length;i++) {
        System.out.print(buf[i]);
      }
    }
  }
  </code></pre>
  
  <p>In cpp programme I am reversing the array and returning the array back to java programee
  My Code is::</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  JNIEXPORT jintArray JNICALL Java_SendArray_loadFile
    (JNIEnv * env, jobject jobj, jintArray array) {
            cout&lt;&lt;"Orignal Array is:"&lt;&lt;endl; 
            int i;
            jboolean j;
            int ar[100];
            // for(i = 0; i &lt; 10; i++){
            int * p= env-&gt;GetIntArrayElements(array, &amp;j);
            //jint *array=env-&gt;GetIntArrayElements(one, 0);
            //ar[i] = array[i];
            //}
  
            for(i = 0 ; i &lt; 10 ; i++){
              cout &lt;&lt; p[i];
            }
  
            for(i = 10 ; i &gt; 0 ; i--){
              ar[10-i] = p[i];
            }
            jintArray ret = env-&gt;NewIntArray(10);
  
            for(i = 0; i &gt;10 ; i++){
              ret[i]=ar[i];
            }
            return ret;
  }
  </code></pre>
  
  <p>error I am gettin is:</p>
  
  <pre><code>error: no match for 'operator=' in '*(ret +((long unsigned int)((long unsigned int)i))) = ar[i]'
  </code></pre>
  
  <p>What should I do to return the array back to java programme???? please help!!!!!</p>