A true testament of the level of integration of Java and R in Renjin is the
ability to directly access (public!) Java classes and methods from R code.
Renjin introduces the import() function which adds a Java class to the
environment from which it is called. In the section
Pushing data from Java to R in the previous chapter we had already
seen how a Java class could be put into the global environment of the R
session.

Consider the following sample R script:

import(java.util.HashMap)# create a new instance of the HashMap class:
ageMap <- HashMap$new()# call methods on the new instance:
ageMap$put("Bob",33)
ageMap$put("Carol",41)print(ageMap$size())
age <- ageMap$get("Carol")cat("Carol is ", age," years old.\n", sep ="")# Java primitives and their boxed types# are automatically converted to R vectors:typeof(age)