I\'m creating a simple program with the possibility to change the language and I would convert the list of properties in the file myBundle.properties in a String array.
Most likely you are getting back a PropertyResourceBundle, which internally uses a HashMap for storage. HashMaps are not ordered.
This is because ResourceBundles should be used for retrieving value by key, not for enumerating in sorted order based on the original property file.
There are two places where I would not assume the order.
1.From the Vector and
2.labels.getKeys();
Try it on a enum that is not instantiated by a collection.
Se if replacing
Enumeration<String> keys = labels.getKeys();
with
List<String> keys = Collections.list( labels.getKeys() );
Collections.sort(keys);
helps
I do not know the exact details of the ResourceBundle class, but when looking at your code example, it seems that it has key/value pairs.
This suggests that it stores its content in an HashMap. (Again, as I do not know ResounrceBundle, this is a hunch) HashMap keys (and values) are unordered as they are stored on such a way that the value can be easily found for a given key.