Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2019-12-23:Kotlin中的数据类型有隐式转换吗?为什么? #217

Open
Moosphan opened this issue Dec 23, 2019 · 4 comments
Open
Labels

Comments

@Moosphan
Copy link
Owner

No description provided.

@Moosphan Moosphan changed the title 2019-12-23:Kotlin中有隐式转换吗?为什么? 2019-12-23:Kotlin中的数据类型有隐式转换吗?为什么? Dec 23, 2019
@1126174422
Copy link

个人理解,kotlin中没有所谓的'基本类型',本质上不存在拆装箱过程,所有的基本类型都可以想象成Java中的包装类型,所以也不存在隐式转换,对应的都是强类型,一旦声明之后,所有转换都是显示转换。

@zhangandroid
Copy link

kotlin 略懂皮毛

@renzhenming
Copy link

有,如下,两个Byte类型相加得到一个int
val b: Byte = 12
var c = b + b
println(c.getClassname()) //class java.lang.Integer

@yline
Copy link

yline commented Sep 2, 2023

应该是有的。例如:val value = "this value is " + 6

6 是整型,会被转换为,”6“,加上去的。而这种代码在python上会直接报错。python 就需要处理为:str(6)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants