当前位置:网站首页>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)
}
边栏推荐
- Stream流
- 偏移量函数及开窗函数
- English语法_名词 - 使用
- MySQL数据库基本操作-DDL | 黑马程序员
- 1005 spell it right (20 points) (pat a)
- node_ Exporter deployment
- The explain statement in MySQL queries whether SQL is indexed, and several types in extra collate and summarize
- BCG 使用之新建向导效果
- socket编程demo二
- Several methods of online database migration
猜你喜欢
Master the use of auto analyze in data warehouse
Lenovo explains in detail the green smart city digital twin platform for the first time to solve the difficulties of urban dual carbon upgrading
C语言-入门-基础-语法-流程控制(七)
Oracle with as ORA-00903: invalid table name 多表报错
TCP两次挥手,你见过吗?那四次握手呢?
多表操作-内连接查询
黑马程序员-软件测试--08阶段2-linux和数据库-23-30-进程端口相关,修改文件权限,端口号信息的获取,程序和进程相关操作,linux命令案例
黑马程序员-软件测试--09阶段2-linux和数据库-31-43修改文件权限字母发的说明,-查找链接修改文件,查找文件命令,链接文件,压缩解压方式,vi编辑器基本使用,
在线SQL转Excel(xls/xlsx)工具
C # use stopwatch to measure the running time of the program
随机推荐
黑马程序员-软件测试--09阶段2-linux和数据库-31-43修改文件权限字母发的说明,-查找链接修改文件,查找文件命令,链接文件,压缩解压方式,vi编辑器基本使用,
Functional interface
An example of multi module collaboration based on NCF
Cbcgpprogressdlg progress bar used by BCG
Stream流
如何使用Async-Awati异步任务处理代替BackgroundWorker?
FTP, SFTP file transfer
Lenovo explains in detail the green smart city digital twin platform for the first time to solve the difficulties of urban dual carbon upgrading
Shell programming core technology II
牛客小白月赛7 谁是神箭手
[QNX Hypervisor 2.2用户手册]6.3.1 工厂页和控制页
Specify the character set to output
指定输出的字符集
YOLOv5s-ShuffleNetV2
牛客小白月赛7 I 新建 Microsoft Office Word 文档
JVM系列之对象的创建
HDU 1372 & POJ 2243 Knight moves (breadth first search)
Hough transform Hough transform principle
Technologie de base de la programmation Shell IV
Online data migration scheme encountered in the project 1 - general idea sorting and technical sorting