I want to create an array that contains the same value repeated for a very large number of times, say 1,000,000.
I was thinking to use something like Array.fill(1000000)(0). However, after reading the documentation for Scala 2.11.8, I found that there is no such members of Array in this version.
Is there any other ways that can create the array without using loop? Thanks in advance for your help.
This will do the trick:
Array.fill[Int](1000000)(0)
Read more here: https://alvinalexander.com/scala/scala-list-class-examples
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With