当前位置:网站首页>Kotlin cycle control
Kotlin cycle control
2022-07-04 19:42:00 【AdleyTales】
fun main() {
val arr = arrayOf(1,2,3)
for ((i,item) in arr.withIndex()){
println("i:$i, item:$item")
}
/**
i:0, item:1
i:1, item:2
i:2, item:3
*/
val items = listOf("apple", "banana", "kiwi")
for (item in items) {
println(item)
}
for (i in items.indices){
println("i: $i, value:${items[i]}")
}
/**
i: 0, value:apple
i: 1, value:banana
i: 2, value:kiwi
*/
// while
var num =10
var sum: Int = 0
while (num > 0){
sum += num
num--
}
println("sum: $sum") // sum: 55
val age = 12
//var n = 5
var n = -5
do {
println("age: $age, n: $n") // age: 12, n: -5
n--
}while (n > 0)
}
边栏推荐
- Pytorch学习(四)
- BCG 使用之CBCGPProgressDlgCtrl进度条使用
- 黑马程序员-软件测试--08阶段2-linux和数据库-23-30-进程端口相关,修改文件权限,端口号信息的获取,程序和进程相关操作,linux命令案例
- . Net ORM framework hisql practice - Chapter 2 - using hisql to realize menu management (add, delete, modify and check)
- Pytest 可视化测试报告之 Allure
- Specify the character set to output
- Stream stream
- The kth largest element in the array
- Oracle with as ora-00903: invalid table name multi report error
- Qt实现界面滑动切换效果
猜你喜欢

Lenovo explains in detail the green smart city digital twin platform for the first time to solve the difficulties of urban dual carbon upgrading

What should we pay attention to when doing social media marketing? Here is the success secret of shopline sellers!

YOLOv5s-ShuffleNetV2

Pythagorean number law (any three numbers can meet the conditions of Pythagorean theorem)

node_ Exporter deployment

mysql中explain语句查询sql是否走索引,extra中的几种类型整理汇总

多表操作-内连接查询

To sort out messy header files, I use include what you use

Comment utiliser async awati asynchrone Task Handling au lieu de backgroundworker?

Online text line fixed length fill tool
随机推荐
HDU 6440 2018中国大学生程序设计网络选拔赛
Educational Codeforces Round 22 E. Army Creation
项目中遇到的线上数据迁移方案1---总体思路整理和技术梳理
Qt实现界面滑动切换效果
Lenovo explains in detail the green smart city digital twin platform for the first time to solve the difficulties of urban dual carbon upgrading
Upgrade the smart switch, how much is the difference between the "zero fire version" and "single fire" wiring methods?
BCG 使用之CBCGPProgressDlgCtrl进度条使用
abc229 总结(区间最长连续字符 图的联通分量计数)
socket编程demo二
【毕业季】绿蚁新醅酒,红泥小火炉。晚来天欲雪,能饮一杯无?
Opencv functions and methods related to binary threshold processing are summarized for comparison and use
Add namespace declaration
92. (cesium chapter) cesium building layering
Niuke Xiaobai month race 7 F question
kotlin 继承
Double colon function operator and namespace explanation
双冒号作用运算符以及命名空间详解
在线文本行固定长度填充工具
线上数据库迁移的几种方法
To sort out messy header files, I use include what you use