当前位置:网站首页>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)
}
边栏推荐
- 一文掌握数仓中auto analyze的使用
- node_exporter部署
- 联想首次详解绿色智城数字孪生平台 破解城市双碳升级难点
- The page element is vertically and horizontally centered, realizing the vertical and horizontal centering of known or unknown width.
- 2014 Hefei 31st youth informatics Olympic Games (primary school group) test questions
- C# 使用StopWatch测量程序运行时间
- Generate XML elements
- 长城证券开户安全吗 买股票怎么开户
- 1011 World Cup Betting (20 分)(PAT甲级)
- Some thoughts on whether the judgment point is located in the contour
猜你喜欢
Hough transform Hough transform principle
SSRS筛选器的IN运算(即包含于)用法
node_exporter部署
To sort out messy header files, I use include what you use
Opencv functions and methods related to binary threshold processing are summarized for comparison and use
YOLOv5s-ShuffleNetV2
Safer, smarter and more refined, Chang'an Lumin Wanmei Hongguang Mini EV?
联想首次详解绿色智城数字孪生平台 破解城市双碳升级难点
MySQL数据库基本操作-DDL | 黑马程序员
勾股数规律(任意三个数能够满足勾股定理需要满足的条件)
随机推荐
876. 链表的中间结点
Online data migration scheme encountered in the project 1 - general idea sorting and technical sorting
2022CoCa: Contrastive Captioners are Image-Text Fountion Models
socket编程demo二
How test engineers "attack the city" (Part I)
Reflection (I)
Pointnet/Pointnet++点云数据集处理并训练
Several methods of online database migration
Hough transform Hough transform principle
勾股数规律(任意三个数能够满足勾股定理需要满足的条件)
The explain statement in MySQL queries whether SQL is indexed, and several types in extra collate and summarize
The 300th weekly match of leetcode (20220703)
Shell 编程核心技术《二》
欧拉函数
1007 Maximum Subsequence Sum(25 分)(PAT甲级)
Wireshark网络抓包
安徽 中安在线文旅频道推出“跟着小编游安徽”系列融媒体产品
mysql中explain语句查询sql是否走索引,extra中的几种类型整理汇总
Stream stream
Wechat reading notes of "work, consumerism and the new poor"