Learn R Programming

rJava (version 1.0-11)

.jinstanceof: Is a java object an instance of a given java class

Description

Is a java object an instance of a given java class

Usage

o %instanceof% cl
.jinstanceof( o, cl )

Value

TRUE if o is an instance of cl

Arguments

o

java object reference

cl

java class. This can be a character vector of length one giving the name of the class, or another java object, or an instance of the Class class, or a object of class jclassName.

Author

Romain Francois <francoisromain@free.fr>

Examples

Run this code
# \dontshow{
.jinit()
# }
Double <- J("java.lang.Double")
d <- new( Double, "10.2" )

# character
d %instanceof% "java.lang.Double"
d %instanceof% "java.lang.Number"

# jclassName
d %instanceof% Double

# instance of Class
Double.class <- Double@jobj
d %instanceof% Double.class

# other object
other.double <- new( Double, 10.2 )
d %instanceof% other.double

# \dontshow{

stopifnot( d %instanceof% "java.lang.Double" )
stopifnot( d %instanceof% "java.lang.Number" )
stopifnot( d %instanceof% "java.lang.Object" )
stopifnot( d %instanceof% Double.class )
stopifnot( d %instanceof% other.double )
stopifnot( d %instanceof% Double )
# }

Run the code above in your browser using DataLab