Bidimension array of int

Eric Gamess egamess@kanaima.ciens.ucv.ve
Thu Sep 2 15:26:00 GMT 1999


Hello,
I am trying to work with bidimensional array. I did a simple example.
A Java file called Borrar.java.
////////////////////// Borrar.java //////////////////////////
class Borrar
{
 static native void visualizar(int a[][]);
 
 public static void main(String args[])
 {
 int a[][]={{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}};
 visualizar(a);
 }
}
//////////////////////////////////////////////////////////////
I did:
 gcj Borrar.java
 gcjh Borrar
I could see that the method ``visualizar'' have the following prototype
void Borrar::visualizar(jobjectArray, jint);
So, I write the following file (Borrar1.cc).
///////////////// Borrar1.cc ////////////////////////////////
#include <cni.h>
#include <stdio.h>
#include "Borrar.h"
 
void Borrar::visualizar(jobjectArray a, jint size)
{
int len=JvGetArrayLength(a);
printf("Length: %d\n", len);
}
///////////////////////////////////////////////////////////////
The compilation is OK, but I cannot link ???????
So, I did the file Borrar2.h and modify Borrar.h (change the prototype)
/////////////////// Borrar2.cc ////////////////////////////////
#include <cni.h>
#include <stdio.h>
#include "Borrar.h"
 
 
void Borrar::visualizar(JArray<JArray<int> *> *a)
{
int len=JvGetArrayLength(a);
printf("Length: %d\n", len);
}
////////////////////////////////////////////////////////////////
And I could compile, link and run the program.
Why gcjh give me protoype:
void Borrar::visualizar(jobjectArray, jint);
instead of prototype:
void Borrar::visualizar(JArray<JArray<int> *> *);
Is there a way to fix it?
Thank you very much for your help.
Eric.
*******************************************************************
Eric Gamess
Universidad Central de Venezuela
Postgrado de Ciencias de la Computacion
Caracas, Venezuela
E-mail: egamess@kanaima.ciens.ucv.ve
Tel: 605-22-93
*******************************************************************


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /