- 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'
推薦閱讀
- Linux C/C++服務器開發實踐
- Cocos2d-x游戲開發:手把手教你Lua語言的編程方法
- Linux核心技術從小白到大牛
- Data Analysis with Stata
- C語言程序設計學習指導與習題解答
- Mastering JBoss Enterprise Application Platform 7
- Mastering Apache Maven 3
- C程序設計實踐教程
- 從零開始學C語言
- ServiceNow:Building Powerful Workflows
- Spring+Spring MVC+MyBatis從零開始學
- Access 2010數據庫應用技術實驗指導與習題選解(第2版)
- IBM Cognos TM1 Developer's Certification guide
- Leaflet.js Essentials
- C++ Windows Programming