0

I've a linkedhashmap that I put into Properties file, and it shows the fields in the menu. I've an others color option and I want it to be seen at the end.

So colormap is my linkedhashmap and I put others the end. So when I look inside colormap, last element is Others. But changes when I put it in properties file.

My code is like this:

colormap.put("Others",Color.GRAY);
Properties prop = new Properties();
prop.putAll(colormap);

And order changes inside prop. Do you have any idea how to solve this problem?

Jeredriq Demas
  • 616
  • 1
  • 9
  • 36

1 Answers1

1

The java.util.Properties type inherits from java.util.Hashtable and there is no guarantee that the table will retain its order even after you've loaded the properties. to fix that you can use OrderedProperties

Messaoud Zahi
  • 1,214
  • 8
  • 15