.jarray takes a vector (or a list of Java references) as its
argument, creates a Java array containing the elements of the vector
(or list) and returns a reference to such newly created array..jarray(x, contents.class = NULL)jobjRef) of a null
object having the specified object class.double[] array, integer vector creates
int[] array, character vector String[] array and so
on. If x is a list, it must contain Java references only (or
NULLs which will be treaded as NULL references). The contents.class parameter is used only if x is a list
of Java object references and it can specify the class that will be
used for all objects in the array. If set to NULL no assumption
is made and java/lang/Object will be used. Use with care and
only if you know what you're doing - you can always use
.jcast to cast the entire array to another type even if
you use a more general object type.
The result is a reference to the newly created array.
The inverse function which fetches the elements of an array reference
is .jevalArray.
a <- .jarray(1:10)
a
.jevalArray(a)
b <- .jarray(c("hello","world"))
b
c <- .jarray(list(a,b))
cRun the code above in your browser using DataLab