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

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

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -