0

Declare var in kotlin without initializing

I have issue in kotlin when declaring a var without initialization like this (var num :Double) , how to define a var of any type without initializing it help me pls I need solution

24th Oct 2021, 10:29 PM
tetsuya
tetsuya - avatar
2 Respuestas
+ 2
I'm not sure what issue you have. Are you looking for something like this? var num = 0 // Int var num = 0.0 // Double var num = '' // Char var num = "" // String
24th Oct 2021, 11:15 PM
Coding Cat
Coding Cat - avatar
+ 2
tetsuya , this should work: fun main(args: Array<String>) { var name: String //other code ... name = "tom" // other code ... println(name) }
25th Oct 2021, 6:46 AM
Lothar
Lothar - avatar