Scala while loop

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/chen18677338530/article/details/91444668

The basic syntax

Here Insert Picture Description

Precautions

Here Insert Picture Description

object Demo18 {
  def main(args: Array[String]): Unit = {
    var i:Int = 0
    while (i < 10){
      println("hello " + i)
      i += 1
    }
  }
}

Here Insert Picture Description

do ... while loop

object Demo19 {
  def main(args: Array[String]): Unit = {
    var i:Int = 0
    do {
      println("hello "+ i)
      i += 1
    } while (i < 10)
  }
}

Here Insert Picture Description

Precautions

Here Insert Picture Description

Guess you like

Origin blog.csdn.net/chen18677338530/article/details/91444668