当前位置:网站首页>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)
}
边栏推荐
- Double colon function operator and namespace explanation
- The 300th weekly match of leetcode (20220703)
- To sort out messy header files, I use include what you use
- 1002. A+B for Polynomials (25)(PAT甲级)
- 牛客小白月赛7 F题
- Comment utiliser async awati asynchrone Task Handling au lieu de backgroundworker?
- Online sql to excel (xls/xlsx) tool
- . Net ORM framework hisql practice - Chapter 2 - using hisql to realize menu management (add, delete, modify and check)
- kotlin 条件控制
- Jetpack Compose 教程
猜你喜欢

升级智能开关,“零火版”、“单火”接线方式差异有多大?

在线SQL转Excel(xls/xlsx)工具

Bi skills - permission axis

2022CoCa: Contrastive Captioners are Image-Text Fountion Models

node_ Exporter deployment

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

YOLOv5s-ShuffleNetV2

Master the use of auto analyze in data warehouse

Lm10 cosine wave homeopathic grid strategy

Hough Transform 霍夫变换原理
随机推荐
1672. 最富有客户的资产总量
Detailed explanation of the binary processing function threshold() of opencv
在线SQL转Excel(xls/xlsx)工具
“只跑一趟”,小区装维任务主动推荐探索
Several methods of online database migration
2014合肥市第三十一届青少年信息学奥林匹克竞赛(小学组)试题
Is it safe to open an account at Great Wall Securities? How to open an account when buying stocks
1003 emergency (25 points) (PAT class a)
LeetCode 赎金信 C#解答
kotlin 条件控制
如何使用Async-Awati异步任務處理代替BackgroundWorker?
Shell 編程核心技術《四》
2019年蜀山区第十五届青少年信息学竞赛
线上数据库迁移的几种方法
Comment utiliser async awati asynchrone Task Handling au lieu de backgroundworker?
FPGA timing constraint sharing 01_ Brief description of the four steps
Shell 编程核心技术《三》
Euler function
有关架构设计的个人思考(本文后续不断修改更新)
Crawler (6) - Web page data parsing (2) | the use of beautifulsoup4 in Crawlers