lundi 2 août 2021

Kotlin - Random numbers without repeating

I have a question, how to prevent random numbers from being repeated. By the way, can someone explain to me how to sort these random numbers?

override fun onCreate(savedInstanceState: Bundle?)
    {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val textView = findViewById<TextView>(R.id.textView)
        val button = findViewById<Button>(R.id.buttom)


        button.setOnClickListener {

            var liczba = List(6){Random.nextInt(1,69)}
            textView.text = liczba.toString()
        }
    }



Aucun commentaire:

Enregistrer un commentaire