Where should I use var and where val ?
Where should I use var and where val ?
Here's a concise answer to your Kotlin interview question:
var and val in KotlinIn Kotlin, you should use:
val (value) for variables that are immutable and don't change their value after initialization.var (variable) for mutable variables that can be reassigned a new value during the program's execution.val when:Đăng nhập để tham gia thảo luận cùng mọi người.
Chưa có bình luận nào
Hãy là người đầu tiên chia sẻ suy nghĩ của bạn.