当前位置:网站首页>Kotlin basic data type
Kotlin basic data type
2022-07-04 19:42:00 【AdleyTales】
fun main() {
// Basic numerical type :
// Double Float Long Int Short Byte
// Use underscores to make numeric constants easier to read
val oneMillion = 1_000_000
val creditCardNumber = 1234_5678_9012_3456L
// 2 Base with 0b start :0b00001011
val bytes = 0b11010010_01101001_10010100_10010010
// Compare two numbers
// stay Kotlin in , Three equal signs === Represents the address of the comparison object , Two == Indicates comparing the size of two values ; Same as JavaScript
val a: Int? = 10000
val b: Int? = 10000
println(a == b) // true
println(a === b) // false
println(a === a) // true
// Type conversion
// toByte() toInt() toShort() toLong() toFloat() toDouble() toChar()
// Boolean true false
// Array
// There are two ways to create an array : One is to use functions arrayOf(); The other is to use factory functions . As shown below , We created two arrays in two ways
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)
}
// character string
val text = """ Multiline string Multiline string """
println(text)
}
边栏推荐
- 联想首次详解绿色智城数字孪生平台 破解城市双碳升级难点
- BCG 使用之新建向导效果
- Online data migration scheme encountered in the project 1 - general idea sorting and technical sorting
- BCG 使用之CBCGPTabWnd控件(相当于MFC TabControl)
- TCP waves twice, have you seen it? What about four handshakes?
- Jetpack compose tutorial
- YOLOv5s-ShuffleNetV2
- MySQL数据库基本操作-DDL | 黑马程序员
- “只跑一趟”,小区装维任务主动推荐探索
- 【问题】druid报异常sql injection violation, part alway true condition not allow 解决方案
猜你喜欢

欧拉函数

92. (cesium chapter) cesium building layering

Hough Transform 霍夫变换原理

HMM隐马尔可夫模型最详细讲解与代码实现

Siemens HMI download prompts lack of panel image solution

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

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

92.(cesium篇)cesium楼栋分层

记一次 .NET 某工控数据采集平台 线程数 爆高分析
Some thoughts on whether the judgment point is located in the contour
随机推荐
Stream stream
Shell programming core technology "I"
1003 emergency (25 points) (PAT class a)
HDU 1372 & POJ 2243 Knight moves (breadth first search)
[QNX Hypervisor 2.2用户手册]6.3.1 工厂页和控制页
牛客小白月赛7 谁是神箭手
明明的随机数
联想首次详解绿色智城数字孪生平台 破解城市双碳升级难点
1011 World Cup betting (20 points) (pat a)
1003 Emergency(25 分)(PAT甲级)
Pythagorean number law (any three numbers can meet the conditions of Pythagorean theorem)
欧拉函数
The difference and usage between substr (), slice (), and substring () in the string interception methods of "understand series after reading"
kotlin 循环控制
1002. A+b for Polynomials (25) (PAT class a)
1005 Spell It Right(20 分)(PAT甲级)
Educational Codeforces Round 22 E. Army Creation
Niuke Xiaobai month race 7 who is the divine Archer
QT realizes interface sliding switching effect
How test engineers "attack the city" (Part I)