Soru & Cevap

android Studio Random metodu ...

15.07.2022 - 03:26

Android studio'da birbirinden farklı yan yana 10 adet sayı,nasıl yapabilirim.Şimdiden teşekkürler.kod ektedir.

57 Görüntülenme

5 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

Profile picture for user sevgii
sevgii
26.12.2022 - 05:05

Random metoduyla rasgele sayılar oluşturduktan sonra if bloğuyla aynı sayı olup olmadığını kontrol edebilirsiniz.

Profile picture for user salihakca
salihakca
11.11.2022 - 11:28

fun random() {

val randomList= List(10) { Random.nextInt(0, 30)

println(randomList)

}

Profile picture for user asimodabas
asimodabas
01.10.2022 - 07:39

fun random() {

val randomList= List(10) { Random.nextInt(0, 30)

println(randomList)

}

Profile picture for user hamza53
hamza53
20.07.2022 - 03:06

 Temel olarak rasgele sayı oluşturman için gerekli kod satırı budur.

Random r = new Random();
int maxDeger = 10;
int textSayilar = r.nextInt(maxDeger);

 

picture-302576-1598380874.png
ogulcankacarr
16.07.2022 - 07:25

selam, yan yanadan neyi kastettin anlamadım dostum, ama şu işine yarayabilir mi?

 

ArrayList<Integer> arrayList = new ArrayList();
        
for (int i=0; i<10;i++){
   Random rnd = new Random();
   int number = rnd.nextInt(20);
   arrayList.add(number);
  }
System.out.println(arrayList);