当前位置:网站首页>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)
}
边栏推荐
猜你喜欢
BCG 使用之新建向导效果
Euler function
There are multiple divs in the large div, which are displayed on the same line. After overflow, scroll bars are generated without line breaks
如何使用Async-Awati异步任務處理代替BackgroundWorker?
关于判断点是否位于轮廓内的一点思考
FPGA timing constraint sharing 01_ Brief description of the four steps
一文掌握数仓中auto analyze的使用
牛客小白月赛7 谁是神箭手
Online text line fixed length fill tool
Introduction to polyfit software
随机推荐
Unity editor extends C to traverse all pictures in folders and subdirectories
Add namespace declaration
node_exporter部署
明明的随机数
Shell 编程核心技术《三》
ftp、sftp文件传输
Find the nth power of 2
SSRS筛选器的IN运算(即包含于)用法
大div中有多个div,这些div在同一行显示,溢出后产生滚动条而不换行
一文掌握数仓中auto analyze的使用
测试工程师如何“攻城”(上)
【问题】druid报异常sql injection violation, part alway true condition not allow 解决方案
The explain statement in MySQL queries whether SQL is indexed, and several types in extra collate and summarize
Shell 編程核心技術《四》
Upgrade the smart switch, how much is the difference between the "zero fire version" and "single fire" wiring methods?
MySQL数据库基本操作-DDL | 黑马程序员
2021 合肥市信息学竞赛小学组
Guys, for help, I use MySQL CDC 2.2.1 (Flink 1.14.5) to write Kafka and set
2022CoCa: Contrastive Captioners are Image-Text Fountion Models
The 15th youth informatics competition in Shushan District in 2019