当前位置:网站首页>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)
}
边栏推荐
- Oracle with as ora-00903: invalid table name multi report error
- 2014 Hefei 31st youth informatics Olympic Games (primary school group) test questions
- HMM隐马尔可夫模型最详细讲解与代码实现
- 2014合肥市第三十一届青少年信息学奥林匹克竞赛(小学组)试题
- prometheus安装
- 求2的n次方
- Pytorch学习(四)
- Educational Codeforces Round 22 E. Army Creation
- 有关架构设计的个人思考(本文后续不断修改更新)
- Introduction to polyfit software
猜你喜欢

Lenovo explains in detail the green smart city digital twin platform for the first time to solve the difficulties of urban dual carbon upgrading

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

SSRS筛选器的IN运算(即包含于)用法

Pointnet/Pointnet++点云数据集处理并训练

The 300th weekly match of leetcode (20220703)

Online text line fixed length fill tool

English语法_名词 - 使用

Stream流

勾股数规律(任意三个数能够满足勾股定理需要满足的条件)

与二值化阈值处理相关的OpenCV函数、方法汇总,便于对比和拿来使用
随机推荐
"Only one trip", active recommendation and exploration of community installation and maintenance tasks
Comment utiliser async awati asynchrone Task Handling au lieu de backgroundworker?
Educational Codeforces Round 22 E. Army Creation
在线文本行固定长度填充工具
Euler function
线上数据库迁移的几种方法
Upgrade the smart switch, how much is the difference between the "zero fire version" and "single fire" wiring methods?
双冒号作用运算符以及命名空间详解
1006 Sign In and Sign Out(25 分)(PAT甲级)
PolyFit软件介绍
English语法_名词 - 使用
2014 Hefei 31st youth informatics Olympic Games (primary school group) test questions
2021 合肥市信息学竞赛小学组
HDU 1097 A hard puzzle
BCG 使用之新建向导效果
Allure of pytest visual test report
Shell 编程核心技术《四》
In flinksql, in addition to data statistics, is the saved data itself a state
1003 emergency (25 points) (PAT class a)
HDU 6440 2018 Chinese college student program design network competition