package kotlinall.chapter1
//kotlin数组
val array_int:IntArray = intArrayOf(1,3,5,7) //java 基本类型定制版本 防止装箱 拆箱
val array_char:CharArray = charArrayOf('5','6','4')
val array_string:Array<String> = arrayOf("ffff","ffaadf","ffasdf")
val array_int1:IntArray = IntArray(5)//数组的初始化
fun main(args:Array<String>){
array_int1.set(0,21)
array_int1.set(1,54)
array_int[3] = 5
for(int in array_int){
println("${int}")
}
println(array_char.size)
println(array_char.joinToString { "," })
println(array_int.slice(0..5))//下标0-5的数据 list
println(array_char::class.java.simpleName)//打印类名
}
kotlin数组
最新推荐文章于 2024-07-03 11:10:08 发布