作者celestialgod (攸蓝)
看板R_Language
标题[问题] rjava 2d string array
时间Sun Mar 8 10:51:19 2015
[问题类型]:
程式谘询
[软体熟悉度]:
使用者
[问题叙述]:
我试着在java回传2d string array
一直给我这样的错误
method getStringMatrix with signature ()[[S not found
[程式范例]:
R code:
library(rJava)
.jinit()
.jaddClassPath("pathToClass")
test = .jnew("Mytest")
out = .jcall(test, "[[S", "getStringMatrix", simplify=TRUE) # error
out2 = .jcall(test, "[[I", "getIntMatrix", simplify=TRUE) # It works
workable code:
out = .jcall(test, "[[Ljava/lang/String;", "getStringMatrix", simplify=TRUE)
java code myTest.java:
public class myTest {
public String[][] getStringMatrix(){
String[][] stringMatrix = new String[][]{{"ABC", "BCD"}, {"CDE", "DEF"}};
return stringMatrix;
}
public int[][] getIntMatrix() {
int[][] intMatrix = new int[][]{{1,2,3},{4,5,6}};
return intMatrix;
}
public static void main(String[] args) {
}
}
[关键字]:
rjava, string array
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 61.224.150.158
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/R_Language/M.1425783081.A.44D.html
1F:→ Wush978: 看起来是java method signature没有兜起来, 可能要问java03/08 19:20
2F:→ Wush978: 专家03/08 19:20
太感谢了!... 我一直google不到相关资讯,方便的话,可以问关键字是下什麽?
4F:→ Wush978: 我忘了耶 XD 03/08 21:48
没关系@@ 我知道下次要直接在stack overflow搜寻...
google搜寻犹如大海捞针....还会自动帮你改关键字~"~
※ 编辑: celestialgod (36.225.213.5), 03/08/2015 23:30:25