- 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'
推薦閱讀
- 深度實踐OpenStack:基于Python的OpenStack組件開發(fā)
- TypeScript Blueprints
- 架構(gòu)不再難(全5冊)
- Vue.js 2 and Bootstrap 4 Web Development
- Software Testing using Visual Studio 2012
- Java程序員面試算法寶典
- Instant Typeahead.js
- C/C++常用算法手冊(第3版)
- Learning Selenium Testing Tools(Third Edition)
- Python:Master the Art of Design Patterns
- 前端HTML+CSS修煉之道(視頻同步+直播)
- Windows內(nèi)核編程
- MySQL從入門到精通(軟件開發(fā)視頻大講堂)
- Android嵌入式系統(tǒng)程序開發(fā):基于Cortex-A8(第2版)
- JavaScript動態(tài)網(wǎng)頁編程