Skip to content

Instantly share code, notes, and snippets.

@rail-rate
Created July 23, 2019 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rail-rate/da5bfd225de3808cbb3e76a5c7a54553 to your computer and use it in GitHub Desktop.
Save rail-rate/da5bfd225de3808cbb3e76a5c7a54553 to your computer and use it in GitHub Desktop.
break1
import java.util.Random //Random()を使うためには先頭に左側コードを書いておく必要があります
fun main(args: Array<String>) {
while(true){
val num = Random().nextInt(10) //ここで0から9までの乱数を生成している
println("乱数:$num") //ここで決まった乱数を表示している
if(num == 0) break //ここで乱数が0ならループから抜ける処理としてbreakを入れている
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment