当前位置:网站首页>kotlin 基本数据类型
kotlin 基本数据类型
2022-07-04 18:32:00 【AdleyTales】
fun main() {
// 基本数值类型:
// Double Float Long Int Short Byte
// 使用下划线使数字常量更易读
val oneMillion = 1_000_000
val creditCardNumber = 1234_5678_9012_3456L
// 2 进制以 0b 开头:0b00001011
val bytes = 0b11010010_01101001_10010100_10010010
// 比较两个数字
// 在 Kotlin 中,三个等号 === 表示比较对象地址,两个 == 表示比较两个值大小;同JavaScript
val a: Int? = 10000
val b: Int? = 10000
println(a == b) // true
println(a === b) // false
println(a === a) // true
// 类型转化
// toByte() toInt() toShort() toLong() toFloat() toDouble() toChar()
// 布尔 true false
// 数组
// 数组的创建两种方式:一种是使用函数arrayOf();另外一种是使用工厂函数。如下所示,我们分别是两种方式创建了两个数组
val arr = arrayOf(11, 22, 33)
println(arr)
for (i in arr) {
println(i)
}
// 2
val arr2 = Array(10) {
x -> x }
for (i in arr2) {
println(i)
}
// 字符串
val text = """ 多行字符串 多行字符串 """
println(text)
}
边栏推荐
- 1002. A+B for Polynomials (25)(PAT甲级)
- Allure of pytest visual test report
- Summary and sorting of 8 pits of redis distributed lock
- 矩阵翻转(数组模拟)
- YOLOv5s-ShuffleNetV2
- Educational Codeforces Round 22 E. Army Creation
- 26. Delete the duplicate item C solution in the ordered array
- “只跑一趟”,小区装维任务主动推荐探索
- 1003 emergency (25 points) (PAT class a)
- Opencv functions and methods related to binary threshold processing are summarized for comparison and use
猜你喜欢
Pythagorean number law (any three numbers can meet the conditions of Pythagorean theorem)
大div中有多个div,这些div在同一行显示,溢出后产生滚动条而不换行
2022CoCa: Contrastive Captioners are Image-Text Fountion Models
Stream流
勾股数规律(任意三个数能够满足勾股定理需要满足的条件)
“只跑一趟”,小区装维任务主动推荐探索
Swagger突然发癫
Lm10 cosine wave homeopathic grid strategy
92.(cesium篇)cesium楼栋分层
Hough Transform 霍夫变换原理
随机推荐
LM10丨余弦波动顺势网格策略
基于NCF的多模块协同实例
HDU 1372 & POJ 2243 Knight Moves(广度优先搜索)
1003 emergency (25 points) (PAT class a)
Several methods of online database migration
2014合肥市第三十一届青少年信息学奥林匹克竞赛(小学组)试题
The kth largest element in the array
1007 Maximum Subsequence Sum(25 分)(PAT甲级)
node_ Exporter deployment
MySQL数据库基本操作-DDL | 黑马程序员
Crawler (6) - Web page data parsing (2) | the use of beautifulsoup4 in Crawlers
矩阵翻转(数组模拟)
Add namespace declaration
876. 链表的中间结点
The explain statement in MySQL queries whether SQL is indexed, and several types in extra collate and summarize
牛客小白月赛7 谁是神箭手
1003 Emergency(25 分)(PAT甲级)
2021 Hefei informatics competition primary school group
Comment utiliser async awati asynchrone Task Handling au lieu de backgroundworker?
Jetpack compose tutorial