How to generate a list of random numbers?

 
 

Share on Google+Share on Google+

Java Coder
How to generate a list of random numbers?
1 Answer(s)      10 days ago
Posted in : Big Data

Hi,

How to generate a list of random numbers?

I want code in scala programming language.

Thanks

Ads
View Answers

November 12, 2017 at 7:13 PM


HI,

You can use the code:

Seq.fill(10)(Random.nextInt)

This is example of Scala programming and it generates random integer.

Following program generates 10 random Integers. Here is the sample output:

scala> import scala.util.Random import scala.util.Random

scala> val s = Seq.fill(10)(Random.nextInt)
s: Seq[Int] = List(-1181870644, 1222939170, 818784821, 
1861087374, 1611361203, 1994029117, -1137498348, 
1659383584, -399814242, -1785355400)

scala>

Thanks


Ads









Ads

 
Advertisement null

Ads