The Array
companion object has some methods to build new arrays, and the one you need is fill
:
val ResampledD = Array.fill(D.length)(D(util.Random.nextInt(D.length)))
or use map
val ResampledD = D map { x => D(util.Random.nextInt(D.length)) }