<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 13, 2015 at 4:35 PM, Nils Chr. Brause <span dir="ltr"><<a href="mailto:nilschrbrause@gmail.com" target="_blank">nilschrbrause@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi,<br>
<span class=""><br>
On Mon, Oct 12, 2015 at 11:08 AM, Pekka Paalanen <<a href="mailto:ppaalanen@gmail.com">ppaalanen@gmail.com</a>> wrote:<br>
> On Mon, 12 Oct 2015 10:41:22 +0200<br>
> Erik De Rijcke <<a href="mailto:derijcke.erik@gmail.com">derijcke.erik@gmail.com</a>> wrote:<br>
><br>
>> Adding enum members is backward compatible for Java. If you compile against<br>
>> an enum with 2 members, and later on a new member is added, you can simply<br>
>> use the new version of the enum.<br>
>><br>
>> Important however is that the order of old members do not change when new<br>
>> members are added.<br>
><br>
> This is important. I don't think anyone has ever mentioned anything<br>
> like this before.<br>
><br>
> We certainly have not expected the order to matter inside an <enum><br>
> tag, since we require the value to be explicitly given. Not when you<br>
> are coming from C, anyway.<br>
<br>
</span>In C++ the order doesn't matter either, since each entry has a defined value.<br>
I wonder why this is different in Java?<br></blockquote><div>Because Java is not C/C++. In Java, enum values are unique by instance alone. It does not have user 'defined' value(s) that make it unique. It *can* have user defined properties (like any object) in addition to implicit compiler generated enum type specific properties. One of those properties is it's "ordinal". Change the order of the enums and the ordinal property will change, which can cause undefined behavior. Now you need to wonder no more. :)</div></div><br></div></div>