I experimented a little with enums and arrays in Java:
enum animals
{CAT, DOG, COW, BIRD, POTATO}
To get this into an array I simply do this...
animals[] creatures = {animals.CAT, animals.POTATO};
But now if I have to define bigger entries, I thought it would be useful if I can just type in the enumeration without animals.XXX, like I also do in C++
animals[] creatures = {CAT, POTATO, BIRD, CAT, CAT, POTATO, COW...}
- It would take time and gives me a better overview
- Java already knows that my target type is 'animals', so in my opinion this is unnecessary (?)
So I just wondered if this is possible in any way, and why if not?
switchsyntax for enums: thecasesin such switch statements cannot becase animals.CAT:etc. but instead they must becase CAT:unlike their use in an array initializer. So you could augment your question by asking, if I can (in fact must) leave out the qualifier incasestatements why can't I do the same in array initializers? (And vice versa of course.)