Created
August 31, 2019 17:07
-
-
Save harshgmp/ece339d8673392a68892ef30ef772d05 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
val variable1 = 10 | |
println(variable1) | |
//variable1 = 20 //Illegal Expression because val can not be reassigned | |
var variable2 = 20 | |
println(variable2) | |
variable2 = 30 | |
println(variable2) | |
//printNum(null) // Illegal Expression because variable a is not nullable | |
printNum(20) | |
printNullNum(null) | |
} | |
fun printNum(a: Int){ | |
println(a) | |
} | |
// Notice the question mark after Int which represents that vara is nullable | |
fun printNullNum(vara: Int?){ | |
println(vara) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment