Issue
I can refer String
in kotlin as String::class.java
but how to refer String...
?
I need to use it to test a private method
private void someMethod(int a, int b, String... c) {
. . .
}
val method: Method = SomeActivity::class.java.getDeclaredMethod(
"someMethod",
Int::class.java,
Int::class.java,
{{need help here}}
)
method.isAccessible = true
method.invoke(activity, 0, 0, "")
Solution
I can refer to it easily using Array<String>::class.java
val method: Method = SomeActivity::class.java.getDeclaredMethod(
"someMethod",
Int::class.java,
Int::class.java,
Array<String>::class.java
)
method.isAccessible = true
method.invoke(activity, 0, 0, arrayOf(""))
Answered By - Madhur Gupta
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.