简体   繁体   English

将 Kotlin 元组传递给 Java function

[英]passing Kotlin Tuple to a Java function

I have a Kotlin function which returns a map like Map<String, Pair<String, String>> .我有一个 Kotlin function ,它返回一个 map ,如Map<String, Pair<String, String>> I need to pass it to a java function and java does not seem to have a Pair data structure.我需要将它传递给 java function 和 java 似乎没有 Pair 数据结构。 What would be the best way to pass such a structure to the Java function?将这样的结构传递给 Java function 的最佳方法是什么?

You can just use Pair ( import kotlin.Pair; ), since that is compiled to a JVM class, this isn't any different from using any other kotlin class in java. You can just use Pair ( import kotlin.Pair; ), since that is compiled to a JVM class, this isn't any different from using any other kotlin class in java.

https://kotlinlang.org/docs/java-to-kotlin-interop.html https://kotlinlang.org/docs/java-to-kotlin-interop.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM