- Android Development with Kotlin
- Marcin Moskala Igor Wojda
- 127字
- 2021-07-02 18:48:36
Char
Characters in Kotlin are stored in type Char. In many ways, characters are similar to strings, so we will concentrate on the similarities and differences. To define Char, we must use single quote, as opposed to a String where we are using double quotes:
val char = 'a' // 1 val string = "a" // 2
- Defines a variable of type Char.
- Defines a variable of type String.
In both characters and strings, special characters can be escaped using a backslash. The following escape sequences are supported:
- \t: Tabulator
- \b: Backspace
- \n: New line
- \r: Carriage-return
- \': Quote
- \": Double quote
- \\: Slash
- \$: Dollar character
- \u: Unicode escape sequence
Let's define a Char containing the Yin Yang Unicode character (U+262F):
var yinYang = '\u262F'
推薦閱讀
- 自然語言處理實戰:預訓練模型應用及其產品化
- 云原生Spring實戰
- Linux環境編程:從應用到內核
- Xamarin.Forms Projects
- 深入淺出PostgreSQL
- Spring 5 Design Patterns
- Android Studio Cookbook
- Scratch從入門到精通
- Learning Unreal Engine Game Development
- Java 7 Concurrency Cookbook
- 讓Python遇上Office:從編程入門到自動化辦公實踐
- 微信公眾平臺開發最佳實踐
- Netty 4核心原理與手寫RPC框架實戰
- Swift語言實戰晉級(第2版)
- 從零開始:Qt可視化程序設計基礎教程