当前位置:网站首页>Kotlin introductory notes (IV) circular statements (simple explanation of while, for)
Kotlin introductory notes (IV) circular statements (simple explanation of while, for)
2022-07-05 09:14:00 【Meng Meng Mu Xi】
Preface : This tutorial is best done with JAVA Study on the basis of
One 、while Use of statements
while Use and java No different
Two 、for Use of statements
Be careful :kotlin Give up for - i loop , take java Of for ( x : xx ) Turned into for - in loop ( It's written a bit like c#, But it's much more flexible )
So let's talk about that kotlin Characteristics of :
kotlin characteristic :
Section
- Closed interval at both ends eg. val range = 0..10 ( Can take 0 To 10, Closed interval at both ends )
- Front open back close interval eg. vla range = 0 until 10 ( You can get it. 0 To 9, Front opening and back closing )
step keyword
By default ,for-in It will increase in the range 1. But if you want to jump some elements , have access to step keyword .
Such as :
fun main() {
for(i in 0 until 10 step 2) {
println(i)
}
}
downTo keyword
Create a descending space
fun main() {
for(i in 10 downTo 1) {
println(i)
}
}
for More about will be explained later ...
边栏推荐
- Nodemon installation and use
- 【PyTorch Bug】RuntimeError: Boolean value of Tensor with more than one value is ambiguous
- Summary and Reflection on issues related to seq2seq, attention and transformer in hands-on deep learning
- Programming implementation of ROS learning 6 -service node
- 交通运输部、教育部:广泛开展水上交通安全宣传和防溺水安全提醒
- C # compare the differences between the two images
- AUTOSAR从入门到精通100讲(103)-dbc文件的格式以及创建详解
- C#绘制带控制点的Bezier曲线,用于点阵图像及矢量图形
- Introduction Guide to stereo vision (2): key matrix (essential matrix, basic matrix, homography matrix)
- 驾驶证体检医院(114---2 挂对应的医院司机体检)
猜你喜欢
Introduction Guide to stereo vision (4): DLT direct linear transformation of camera calibration [recommended collection]
Hi Fun Summer, play SQL planner with starrocks!
fs. Path module
Wxml template syntax
Confusing basic concepts member variables local variables global variables
Multiple solutions to one problem, asp Net core application startup initialization n schemes [Part 1]
Progressive JPEG pictures and related
nodejs_ 01_ fs. readFile
Programming implementation of ROS learning 2 publisher node
Applet global style configuration window
随机推荐
[code practice] [stereo matching series] Classic ad census: (4) cross domain cost aggregation
什么是防火墙?防火墙基础知识讲解
Programming implementation of ROS learning 6 -service node
Chris LATTNER, the father of llvm: why should we rebuild AI infrastructure software
12. Dynamic link library, DLL
信息與熵,你想知道的都在這裏了
Applet data attribute method
生成对抗网络
2311. 小于等于 K 的最长二进制子序列
Editor use of VI and VIM
基于STM32单片机的测温仪(带人脸检测)
File server migration scheme of a company
Use arm neon operation to improve memory copy speed
Illustrated network: what is gateway load balancing protocol GLBP?
C # draw Bezier curve with control points for lattice images and vector graphics
kubeadm系列-02-kubelet的配置和启动
Beautiful soup parsing and extracting data
嗨 FUN 一夏,与 StarRocks 一起玩转 SQL Planner!
【PyTorch Bug】RuntimeError: Boolean value of Tensor with more than one value is ambiguous
Codeforces Round #648 (Div. 2) D. Solve The Maze