- Kotlin for Enterprise Applications using Java EE
- Raghavendra Rao K
- 217字
- 2021-06-10 18:49:18
Data types in Kotlin
The basic data types in Kotlin are numbers, characters, Boolean, arrays, and strings. These are described as follows:
- Number: Kotlin provides the following built-in types that represent numbers, similar to Java:

Unlike in Java, c haracters are not nu mbers in Kotlin.
-
- Byte: Byte is a one-byte or 8-bit type for which values range from -128 to 127
- Short: Short is a two-byte or 16-bit type for which values range from -32768 to 32767
- Int: Int is a four-byte or 32-bit type for which values range from -2^31 to 2^31-1
- Long: Long is an eight-byte or 64-bit type that can have values from -2^63 to 2^63-1
- Double: Double is a double-precision, 8-byte, or 64-bit floating point
- Float: Float is a single-precision, 4-byte or 32-bit floating point
- Char: Char is used to represent a character in Kotlin, two-byte or 16-bit long, and is used to represent unicode characters
Char is a type used to represent characters. This is represented as follows:
val ch = 'a'
- Boolean: Kotlin has a Boolean type to represent Booleans. It takes either true or false:
val isValid = true
val flag = false
If you are using IntelliJ IDEA, you can place your cursor inside the variable and press Ctrl + Shift + P to see its type.
推薦閱讀
- Vue.js 3.x快速入門
- MySQL數據庫管理實戰
- Hands-On Machine Learning with scikit:learn and Scientific Python Toolkits
- Monkey Game Development:Beginner's Guide
- Java異步編程實戰
- jQuery EasyUI網站開發實戰
- Silverlight魔幻銀燈
- .NET 3.5編程
- HTML5+CSS3 Web前端開發技術(第2版)
- IoT Projects with Bluetooth Low Energy
- Vue.js 3應用開發與核心源碼解析
- Penetration Testing with the Bash shell
- 視窗軟件設計和開發自動化:可視化D++語言
- Kotlin語言實例精解
- Mastering Machine Learning with scikit-learn