How to generate a random number in Kotlin - Kotlin Snippets

Published: 21 February 2022
on channel: Programming With Nick
1,819
32

Kotlin Snippets - How to generate a random number in Kotlin.

The easiest way to generate a random number in Koltin is to use its own multiplatform random generator.

For example, if we want a random number from 0 to 100 included we can just type:

val randomNumber = (0..100).random()


Watch video How to generate a random number in Kotlin - Kotlin Snippets online without registration, duration hours minute second in high quality. This video was added by user Programming With Nick 21 February 2022, don't forget to share it with your friends and acquaintances, it has been viewed on our site 1,819 once and liked it 32 people.