rjava将int传递给构造函数
我定义了一个带有不同参数的构造函数的Java类。如果我尝试在r obj< - 。jnew中创建一个Java对象('testrjava/testrjava',“ hello”,“ world”)
或 obj< - 。 /testrjava',“ Hello World”)按预期工作。但是,如果我尝试通过一个像obj< - 。
.jnew中的错误(“ testrjava/testrjava”,“ Hello”,123):
java.lang.nosuchmethoderror:< init>
在Java端,我肯定定义了构造函数public testrjava(String param1,int param2){...
和rjava doc说:
将传递给相应构造函数的任何参数。 参数类型是自动确定和/或从 JobJref对象。有关详细信息,请参见.jcall。请注意,所有命名参数 被丢弃。
但是我找不到如何通过整数。我是否必须使用.jcast
或其他任何内容?
I defined a java class with several constructors with different parameters. If I try to create a java object in R via obj<-.jnew('testRJava/TestRJava', "Hello", "World")
or obj<-.jnew('testRJava/TestRJava', "Hello world")
everthing working as expected. But if I try to pass an Integer like obj<-.jnew('testRJava.TestRJava', "Hello", 123)
the following error is thrown:
Error in .jnew("testRJava/TestRJava", "Hello", 123) :
java.lang.NoSuchMethodError: <init>
On Java side I definitly defined the constructor public TestRJava(String param1, int param2) {...
and the rjava doc says:
Any parameters that will be passed to the corresponding constructor.
The parameter types are determined automatically and/or taken from the
jobjRef object. For details see .jcall. Note that all named parameters
are discarded.
But I can't find how to pass an integer. Do I have to use .jcast
or anything else?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
123是双重。 123L是一个(长)整数。
123 is a double. 123L is a (long) integer.