当前位置:网站首页>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 ...
边栏推荐
- Luo Gu p3177 tree coloring [deeply understand the cycle sequence of knapsack on tree]
- notepad++
- [code practice] [stereo matching series] Classic ad census: (4) cross domain cost aggregation
- Applet customization component
- 2310. 个位数字为 K 的整数之和
- C#绘制带控制点的Bezier曲线,用于点阵图像及矢量图形
- 信息与熵,你想知道的都在这里了
- C#图像差异对比:图像相减(指针法、高速)
- 【PyTorch Bug】RuntimeError: Boolean value of Tensor with more than one value is ambiguous
- Global configuration tabbar
猜你喜欢

【ManageEngine】如何利用好OpManager的报表功能

什么是防火墙?防火墙基础知识讲解

Introduction Guide to stereo vision (1): coordinate system and camera parameters

Node collaboration and publishing

My experience from technology to product manager

Introduction Guide to stereo vision (7): stereo matching

AUTOSAR from getting started to mastering 100 lectures (103) -dbc file format and creation details

Hi Fun Summer, play SQL planner with starrocks!

顶会论文看图对比学习(GNN+CL)研究趋势

2020 "Lenovo Cup" National College programming online Invitational Competition and the third Shanghai University of technology programming competition
随机推荐
Talking about label smoothing technology
Confusing basic concepts member variables local variables global variables
Introduction Guide to stereo vision (7): stereo matching
Oracle advanced (III) detailed explanation of data dictionary
OpenGL - Coordinate Systems
Multiple solutions to one problem, asp Net core application startup initialization n schemes [Part 1]
混淆矩阵(Confusion Matrix)
scipy. misc. imread()
Summary and Reflection on issues related to seq2seq, attention and transformer in hands-on deep learning
Install the CPU version of tensorflow+cuda+cudnn (ultra detailed)
ROS learning 1- create workspaces and function packs
利用请求头开发多端应用
嗨 FUN 一夏,与 StarRocks 一起玩转 SQL Planner!
Codeworks round 681 (Div. 2) supplement
The location search property gets the login user name
Codeforces Round #648 (Div. 2) E.Maximum Subsequence Value
Solution to the problems of the 17th Zhejiang University City College Program Design Competition (synchronized competition)
【PyTorch Bug】RuntimeError: Boolean value of Tensor with more than one value is ambiguous
编辑器-vi、vim的使用
12. Dynamic link library, DLL