当前位置:网站首页>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)
}
边栏推荐
- Oracle with as ORA-00903: invalid table name 多表报错
- HDU 1372 & POJ 2243 Knight Moves(广度优先搜索)
- Hough transform Hough transform principle
- Add namespace declaration
- 添加命名空间声明
- [QNX Hypervisor 2.2用户手册]6.3.1 工厂页和控制页
- 1011 World Cup betting (20 points) (pat a)
- To sort out messy header files, I use include what you use
- Double colon function operator and namespace explanation
- "Only one trip", active recommendation and exploration of community installation and maintenance tasks
猜你喜欢
Master the use of auto analyze in data warehouse
PointNeXt:通过改进的模型训练和缩放策略审视PointNet++
黑马程序员-软件测试--08阶段2-linux和数据库-23-30-进程端口相关,修改文件权限,端口号信息的获取,程序和进程相关操作,linux命令案例
Stream stream
92.(cesium篇)cesium楼栋分层
Online sql to excel (xls/xlsx) tool
Lenovo explains in detail the green smart city digital twin platform for the first time to solve the difficulties of urban dual carbon upgrading
How to use async Awati asynchronous task processing instead of backgroundworker?
西门子HMI下载时提示缺少面板映像解决方案
多表操作-外连接查询
随机推荐
FTP, SFTP file transfer
Specify the character set to output
Qt实现界面滑动切换效果
Add namespace declaration
kotlin 基本使用
Shell programming core technology "three"
c# .net mvc 使用百度Ueditor富文本框上传文件(图片,视频等)
函数式接口
Niuke Xiaobai month race 7 F question
1008 Elevator(20 分)(PAT甲级)
Explore the contour drawing function drawcontours() of OpenCV in detail with practical examples
Find the nth power of 2
Oracle with as ora-00903: invalid table name multi report error
kotlin 继承
指定输出的字符集
Niuke Xiaobai month race 7 e applese's super ability
There are multiple divs in the large div, which are displayed on the same line. After overflow, scroll bars are generated without line breaks
1005 Spell It Right(20 分)(PAT甲级)
长城证券开户安全吗 买股票怎么开户
BCG 使用之CBCGPProgressDlgCtrl进度条使用