byte array in groovy byte array in groovy arrays arrays

byte array in groovy


The following should suffice:

def array = [0, 0, 0, 0, 0] as byte[]

Have a look here for more details on arrays in groovy.


In addition to rich.okelly's answer,

byte[] array = [0, 0, 0, 0, 0]

works as well


You can't initialize a literal array the same way because Groovy thinks the curly brackets form a closure. What you want is something like

def x = [ 0, 0, 0, 0, 0 ] as byte[]

See more: here