lonelyloner lonelyloner - 9 months ago 48
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!

Answer Source

You are missing one tiny part of the Array declaration.

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