使用"Kt"的原因是什么?后缀在Kotlin类中? [英] What is the reason for using "Kt" suffix in Kotlin classes?

查看:393
本文介绍了使用"Kt"的原因是什么?后缀在Kotlin类中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Kotlin文档中找到有关此决定的更多详细信息,但没有讨论"此节的内容.有谁知道是什么决定决定在Kotlin的类名中使用"Kt"后缀?是为了避免与Java类名冲突,还是还有更多呢?

I was trying to find more details about this decision in the Kotlin documentation but there is no section that "talks" about it. Does anyone know what drove the decision to use the "Kt" suffix in class names in Kotlin? Is it to avoid collision with Java class names, or is there more to it?

推荐答案

与Java不同,Kotlin允许您定义不在类内部的函数.但是,如果您想让Java与Kotlin对话,那就成了问题.怎么解决呢?将这些函数转换为带有"Kt"后缀的名为文件的类的静态方法

Unlike Java, Kotlin allows you to define functions that are not inside a class. But if you want Java to talk to Kotlin that becomes a problem. How to solve it? Convert those functions into static methods of a class named as the file with the "Kt" suffix

您可以在文档

这篇关于使用"Kt"的原因是什么?后缀在Kotlin类中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆