当前位置:网站首页>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 ...
边栏推荐
- OpenGL - Coordinate Systems
- Transfer learning and domain adaptation
- Mengxin summary of LIS (longest ascending subsequence) topics
- Mengxin summary of LCs (longest identical subsequence) topics
- Node collaboration and publishing
- It's too difficult to use. Long articles plus pictures and texts will only be written in short articles in the future
- Progressive JPEG pictures and related
- [code practice] [stereo matching series] Classic ad census: (6) multi step parallax optimization
- Applet global style configuration window
- Explain NN in pytorch in simple terms CrossEntropyLoss
猜你喜欢
OpenGL - Coordinate Systems
[code practice] [stereo matching series] Classic ad census: (4) cross domain cost aggregation
Blogger article navigation (classified, real-time update, permanent top)
Understanding rotation matrix R from the perspective of base transformation
信息与熵,你想知道的都在这里了
Ros-10 roslaunch summary
Introduction Guide to stereo vision (6): level constraints and polar correction of fusiello method
顶会论文看图对比学习(GNN+CL)研究趋势
What is a firewall? Explanation of basic knowledge of firewall
Use and programming method of ros-8 parameters
随机推荐
2309. The best English letters with both upper and lower case
MPSoC QSPI flash upgrade method
我的一生.
Add discount recharge and discount shadow ticket plug-ins to the resource realization applet
一题多解,ASP.NET Core应用启动初始化的N种方案[上篇]
Mengxin summary of LIS (longest ascending subsequence) topics
Confusion matrix
Svgo v3.9.0+
Multiple linear regression (gradient descent method)
编辑器-vi、vim的使用
Node collaboration and publishing
Return of missing persons
The location search property gets the login user name
Introduction Guide to stereo vision (7): stereo matching
2309. 兼具大小写的最好英文字母
OpenGL - Model Loading
Causes and appropriate analysis of possible errors in seq2seq code of "hands on learning in depth"
2310. The number of bits is the sum of integers of K
顶会论文看图对比学习(GNN+CL)研究趋势
Wxml template syntax