当前位置:网站首页>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)
}
边栏推荐
- 勾股数规律(任意三个数能够满足勾股定理需要满足的条件)
- 2021 Hefei informatics competition primary school group
- Guys, for help, I use MySQL CDC 2.2.1 (Flink 1.14.5) to write Kafka and set
- YOLOv5s-ShuffleNetV2
- 1011 World Cup Betting (20 分)(PAT甲级)
- Qt实现界面滑动切换效果
- Unity adds a function case similar to editor extension to its script, the use of ContextMenu
- 有关架构设计的个人思考(本文后续不断修改更新)
- Have you guys ever used CDC direct Mysql to Clickhouse
- Euler function
猜你喜欢

Detailed explanation of the binary processing function threshold() of opencv

To sort out messy header files, I use include what you use

PolyFit软件介绍

Master the use of auto analyze in data warehouse

92.(cesium篇)cesium楼栋分层

Oracle with as ORA-00903: invalid table name 多表报错

联想首次详解绿色智城数字孪生平台 破解城市双碳升级难点

node_exporter部署

FPGA时序约束分享01_四大步骤简述

升级智能开关,“零火版”、“单火”接线方式差异有多大?
随机推荐
Reflection (I)
升级智能开关,“零火版”、“单火”接线方式差异有多大?
线上数据库迁移的几种方法
反射(一)
The 300th weekly match of leetcode (20220703)
Jetpack Compose 教程
1003 emergency (25 points) (PAT class a)
The explain statement in MySQL queries whether SQL is indexed, and several types in extra collate and summarize
FPGA时序约束分享01_四大步骤简述
Shell programming core technology II
欧拉函数
关于判断点是否位于轮廓内的一点思考
Shell programming core technology "four"
1009 Product of Polynomials(25 分)(PAT甲级)
HDU 6440 2018 Chinese college student program design network competition
Crawler (6) - Web page data parsing (2) | the use of beautifulsoup4 in Crawlers
Wireshark网络抓包
Lenovo explains in detail the green smart city digital twin platform for the first time to solve the difficulties of urban dual carbon upgrading
西门子HMI下载时提示缺少面板映像解决方案
Summary and sorting of 8 pits of redis distributed lock