当前位置:网站首页>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)
}
边栏推荐
- Pointnet/Pointnet++点云数据集处理并训练
- HDU 1097 A hard puzzle
- 添加命名空间声明
- An example of multi module collaboration based on NCF
- How test engineers "attack the city" (Part I)
- BCG 使用之CBCGPProgressDlg进度条使用
- Qt实现界面滑动切换效果
- BCG 使用之新建向导效果
- There are multiple divs in the large div, which are displayed on the same line. After overflow, scroll bars are generated without line breaks
- 有关架构设计的个人思考(本文后续不断修改更新)
猜你喜欢

YOLOv5s-ShuffleNetV2

在线文本行固定长度填充工具

92.(cesium篇)cesium楼栋分层

【问题】druid报异常sql injection violation, part alway true condition not allow 解决方案
Summary and sorting of 8 pits of redis distributed lock

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

西门子HMI下载时提示缺少面板映像解决方案

如何使用Async-Awati异步任务处理代替BackgroundWorker?

如何使用Async-Awati异步任務處理代替BackgroundWorker?

Bi skills - permission axis
随机推荐
Stream stream
BCG 使用之CBCGPProgressDlgCtrl进度条使用
指定输出的字符集
HDU 1097 A hard puzzle
mysql中explain语句查询sql是否走索引,extra中的几种类型整理汇总
用实际例子详细探究OpenCV的轮廓绘制函数drawContours()
The page element is vertically and horizontally centered, realizing the vertical and horizontal centering of known or unknown width.
C# 使用StopWatch测量程序运行时间
Hough Transform 霍夫变换原理
How to use async Awati asynchronous task processing instead of backgroundworker?
【问题】druid报异常sql injection violation, part alway true condition not allow 解决方案
Use canal and rocketmq to listen to MySQL binlog logs
牛客小白月赛7 谁是神箭手
Wechat reading notes of "work, consumerism and the new poor"
BCG 使用之新建向导效果
Explicit random number
Shell 编程核心技术《三》
English grammar_ Noun - use
HDU 6440 2018 Chinese college student program design network competition
How test engineers "attack the city" (Part 2)