mercredi 4 septembre 2019

How do i generate a 4-digit pin with no duplicating number

I'm new to android programming and i want to make a 4 Digit PIN generator without any repeats. How do I do it?? I don't know how to loop that very well yet. Thank you!!

I already tried Random but it gives me numbers that repeat.

int randomPIN = (int)(Math.random()*9000)+1000;

String pin = String.valueOf(randomPIN);
dummy.setText(pin);

I'm looking for an outcome of 1354, 4682, 3645 but the results are mostly 3344, 6577, 1988




Aucun commentaire:

Enregistrer un commentaire