lonelyloner lonelyloner - 5 months ago 34
Java Question

Java array of enum values

Machine is defined as

public enum Machine{...}

is defined as
private Machine[] _machines;

Don't know why this doesn't work:

_machines = {Machine.a, Machine.b};

error message:

illegal start of expression

Thank you guys!


You are missing one tiny part of the Array declaration.

_machines = new Machine[]{Machine.a, Machine.b};