当前位置:网站首页>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 ...
边栏推荐
- 深入浅出PyTorch中的nn.CrossEntropyLoss
- TF coordinate transformation of common components of ros-9 ROS
- Introduction Guide to stereo vision (3): Zhang calibration method of camera calibration [ultra detailed and worthy of collection]
- 太不好用了,长文章加图文,今后只写小短文
- Add discount recharge and discount shadow ticket plug-ins to the resource realization applet
- It's too difficult to use. Long articles plus pictures and texts will only be written in short articles in the future
- Meta tag details
- Summary of "reversal" problem in challenge Programming Competition
- Progressive JPEG pictures and related
- Mengxin summary of LCs (longest identical subsequence) topics
猜你喜欢
Editor use of VI and VIM
Introduction Guide to stereo vision (2): key matrix (essential matrix, basic matrix, homography matrix)
Summary of "reversal" problem in challenge Programming Competition
L'information et l'entropie, tout ce que vous voulez savoir est ici.
优先级队列(堆)
[code practice] [stereo matching series] Classic ad census: (6) multi step parallax optimization
Beautiful soup parsing and extracting data
22-07-04 西安 尚好房-项目经验总结(01)
Blogger article navigation (classified, real-time update, permanent top)
Confusion matrix
随机推荐
Blue Bridge Cup provincial match simulation question 9 (MST)
Ecmascript6 introduction and environment construction
Oracle advanced (III) detailed explanation of data dictionary
[beauty of algebra] solution method of linear equations ax=0
kubeadm系列-02-kubelet的配置和启动
Svgo v3.9.0+
阿里云发送短信验证码
C#图像差异对比:图像相减(指针法、高速)
Wxml template syntax
Solution to the problem of the 10th Programming Competition (synchronized competition) of Harbin University of technology "Colin Minglun Cup"
我的一生.
Array, date, string object method
MPSoC QSPI flash upgrade method
Install the CPU version of tensorflow+cuda+cudnn (ultra detailed)
云计算技术热点
AdaBoost use
It's too difficult to use. Long articles plus pictures and texts will only be written in short articles in the future
Huber Loss
Pearson correlation coefficient
Explain NN in pytorch in simple terms CrossEntropyLoss