当前位置:网站首页>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)
}
边栏推荐
- 92.(cesium篇)cesium楼栋分层
- Educational codeforces round 22 E. Army Creation
- FTP, SFTP file transfer
- Shell programming core technology "three"
- 《工作、消费主义和新穷人》的微信读书笔记
- Master the use of auto analyze in data warehouse
- @transactional滥用导致数据源连接池耗尽问题
- English grammar_ Noun - use
- The page element is vertically and horizontally centered, realizing the vertical and horizontal centering of known or unknown width.
- 多表操作-内连接查询
猜你喜欢
There are multiple divs in the large div, which are displayed on the same line. After overflow, scroll bars are generated without line breaks
Niuke Xiaobai month race 7 who is the divine Archer
在线文本行固定长度填充工具
FPGA timing constraint sharing 01_ Brief description of the four steps
西门子HMI下载时提示缺少面板映像解决方案
Swagger突然发癫
Pytorch学习(四)
如何使用Async-Awati异步任务处理代替BackgroundWorker?
大div中有多个div,这些div在同一行显示,溢出后产生滚动条而不换行
线上数据库迁移的几种方法
随机推荐
线上数据库迁移的几种方法
Stream stream
PolyFit软件介绍
SSRS筛选器的IN运算(即包含于)用法
数据集划分
The explain statement in MySQL queries whether SQL is indexed, and several types in extra collate and summarize
How test engineers "attack the city" (Part 2)
多表操作-外连接查询
Niuke Xiaobai monthly race 7 I new Microsoft Office Word document
Upgrade the smart switch, how much is the difference between the "zero fire version" and "single fire" wiring methods?
There are multiple divs in the large div, which are displayed on the same line. After overflow, scroll bars are generated without line breaks
C # use stopwatch to measure the running time of the program
Allure of pytest visual test report
勾股数规律(任意三个数能够满足勾股定理需要满足的条件)
Cbcgpprogressdlg progress bar used by BCG
有关架构设计的个人思考(本文后续不断修改更新)
kotlin 基本数据类型
kotlin 循环控制
Mysql database basic operation -ddl | dark horse programmer
Siemens HMI download prompts lack of panel image solution