我知道在 R 中调用 java 接口的两种表达式。例如 public void add(int a,int b){}
,类中有一个 java 函数定义Test
library(rJava)
.jinit()
.jaddClassPath(dir( "lib", full.names=T ))
Test = J('...Test')
test = new(Test)
a = as.integer(3)
b = as.integer(4)
.jcall(test,'V','add',a,b) #first type of expression
test$add(a,b) #second type of expression
我测试了两种表达方式,第一种比第二种效率高得多。我想知道原因的细节。非常感谢。