new: Create a new Java object

Description Details Methods See Also Examples

Description

Creates a new Java object and invokes the constructor with given arguments.

Details

The new method is used as the high-level API to create new Java objects (for low-level access see .jnew). It returns the newly created Java object.

... arguments are passed to the constructor of the class specified as J("class.name").

Methods

new

signature(Class = "jclassName"): ...

See Also

.jnew, jclassName-class

Examples

1
2
3
4
5
6
7
## Not run: 
v <- new(J("java.lang.String"), "Hello World!")
v$length()
v$indexOf("World")
names(v)

## End(Not run)

rJava documentation built on Dec. 11, 2021, 9:25 a.m.

Related to new in rJava...