Search

Basic Type

Kotlin에서 변수는 멤버 함수와 속성을 호출할 수 있다는 점에서 모두 객체이다.
특정 타입은 런타임 시 기본 타입으로 최적화된 내부 타입을 사용한다.
숫자 타입을 함수의 매개변수로 넘길 땐 암시적 확장 변환이 없으므로 명시적 변환을 해줘야한다.
변수를 선언하기 위해선 : 와 함께 타입을 명시해야한다.
// Variable declared without initialization val d: Int // Variable initialized d = 3 // Variable explicitly typed and initialized val e: String = "hello" // Variables can be read because they have been initialized println(d) // 3 println(e) // hello
Kotlin
복사
Category
Basic Types
Integers
Byte, Short, Int, Long
Unsigned Integers
UByte, UShort, UInt, ULong
Floating-point numbers
Float, Double
Booleans
Boolean
Characters
Char
Strings
String