当前位置:网站首页>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)
}
边栏推荐
- What should we pay attention to when doing social media marketing? Here is the success secret of shopline sellers!
- BCG 使用之CBCGPProgressDlgCtrl进度条使用
- SSRS筛选器的IN运算(即包含于)用法
- TCP waves twice, have you seen it? What about four handshakes?
- Lenovo explains in detail the green smart city digital twin platform for the first time to solve the difficulties of urban dual carbon upgrading
- Matrix flip (array simulation)
- Is it safe to open an account at Great Wall Securities? How to open an account when buying stocks
- 1002. A+B for Polynomials (25)(PAT甲级)
- HDU 1372 & POJ 2243 Knight Moves(广度优先搜索)
- Oracle with as ORA-00903: invalid table name 多表报错
猜你喜欢
What should we pay attention to when doing social media marketing? Here is the success secret of shopline sellers!
Mysql database basic operation -ddl | dark horse programmer
Online sql to excel (xls/xlsx) tool
勾股数规律(任意三个数能够满足勾股定理需要满足的条件)
Introduction to polyfit software
YOLOv5s-ShuffleNetV2
BCG 使用之CBCGPProgressDlg进度条使用
Comment utiliser async awati asynchrone Task Handling au lieu de backgroundworker?
黑马程序员-软件测试--08阶段2-linux和数据库-23-30-进程端口相关,修改文件权限,端口号信息的获取,程序和进程相关操作,linux命令案例
92.(cesium篇)cesium楼栋分层
随机推荐
西门子HMI下载时提示缺少面板映像解决方案
HDU 6440 2018 Chinese college student program design network competition
Shell programming core technology II
1007 Maximum Subsequence Sum(25 分)(PAT甲级)
黑马程序员-软件测试--08阶段2-linux和数据库-23-30-进程端口相关,修改文件权限,端口号信息的获取,程序和进程相关操作,linux命令案例
1003 Emergency(25 分)(PAT甲级)
abc229 总结(区间最长连续字符 图的联通分量计数)
An example of multi module collaboration based on NCF
What should we pay attention to when doing social media marketing? Here is the success secret of shopline sellers!
“只跑一趟”,小区装维任务主动推荐探索
【问题】druid报异常sql injection violation, part alway true condition not allow 解决方案
BCG 使用之CBCGPProgressDlg进度条使用
1007 maximum subsequence sum (25 points) (PAT class a)
Allure of pytest visual test report
FPGA时序约束分享01_四大步骤简述
TCP两次挥手,你见过吗?那四次握手呢?
Shell programming core technology "three"
Crawler (6) - Web page data parsing (2) | the use of beautifulsoup4 in Crawlers
Online sql to excel (xls/xlsx) tool
The kth largest element in the array