java - enum.values() - is an order of returned enums deterministic -


i have enum some_enum:

public enum some_enum {   en_one,   en_two,   en_three; } 

will some_enum.values() return enums in order of enum declarations: en_one, en_two, en_three? rule or not guaranteed not changed in next jdk releases?

the java language specification uses explicit language:

@return array containing constants of enum type, in order they're declared [source]

so, yes, returned in declaration order. it's worth noting order might change on time if changes class careful how use this.


Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -