Reputation:
I have a class one in java which implements AsyncTask and other is kotlin MainActivity.
Now I have a kotlin function with kotlin int as parameter in MainActivity. I have managed to call kotlin function in java class but unable to pass Java Integer,it shows compile time error. Is there any way to pass integer value?
Upvotes: 2
Views: 1172
Reputation: 2348
From your post, I guess that the compile error occurred due to using int
instead of Int
in Kotlin. Change your kotlin function to this
fun kotlinfun(i: Int){
...
}
and call normally in java class
int k=0;
obj.kotlinfun(k);
Upvotes: 1
Reputation: 332
Try it:
int k=0;
obj.kotlinfun(String.valueOf(k));
Upvotes: 0
Reputation: 171
Java using int
instead Integer
,
and in java to parse integer to string using Integer.toString(k)
Upvotes: 2