kotlin global variable
var x = 100
fun fn() {
x = x + 100
}
fun main(args: Array<String>) {
println("X Value : $x")
fn()
println("X Value : $x")
}
kotlin global variable
var x = 100
fun fn() {
x = x + 100
}
fun main(args: Array<String>) {
println("X Value : $x")
fn()
println("X Value : $x")
}
kotlin global variable
In Kotlin, A global variable is a variable that is declared at the top of the program and outside all functions similar to C and C++. A local variable can only be used in the particular block where it is declared. A global variable can be used in all functions.
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us