wyljpn / training-scala-basics

1 stars 0 forks source link

課題9-2 #10

Closed wyljpn closed 4 years ago

wyljpn commented 4 years ago

2.Oracle Java TutorialsのPausing Execution with Sleepのコード例を、IDEからScalaで実装して実行結果を貼り付けて下さい。

package kadai09

object SleepMessages {

  def main(args: Array[String]): Unit = {

    val importantInfo = Array("Mares eat oats", "Does eat oats", "Little lambs eat ivy", "A kid will eat ivy too")

    for (i <- importantInfo.indices) {
      //Pause for 4 seconds
      Thread.sleep(4000)
      //Print a message
      println(importantInfo(i))
    }

  }
}

output:

Mares eat oats
Does eat oats
Little lambs eat ivy
A kid will eat ivy too
richardimaoka commented 4 years ago

OKです!