Gary Sieling

Scala: new byte array

To create a new byte arrays in scala, you have two options.

To initialize it with data, you can do this:

val data = Array[Byte](10, -32, 17, 22)

If you want to initialize it to a specific length like a Java array, do this:

val length = 1000
Array.fill[Byte](length)(0)
Exit mobile version