Programming/Kotlin
Kotlin Variable
Albothyl
2022. 4. 16. 10:25
- val
- 불변
- Getter 메소드만 제공
- var
- 가변
- Getter, Setter 메소드 제공
-
val a: Int = 1 // immediate assignment val b = 2 // `Int` type is inferred val c: Int // Type required when no initializer is provided c = 3 // deferred assignment. c에 값을 다시 할당하면 exception 발생