3

I want to create a static final Map instance which consists of specific Roman Numeral symbols and their corresponding numeric value. I tried to write the following code:

    Map.of("I", 1, 
            "IV", 4, 
            "V", 5, 
            "IX", 9, 
            "X", 10, 
            "XL", 40, 
            "L", 50, 
            "XC", 90, 
            "C", 100,
            "CD", 400, 
            "D", 500, 
            "CM", 900, 
            "M", 1000);

but I received an error because Map.of wouldn't take that many arguments. How can I cleanly create a static final Map with all of my pairs?

Irene Serrano
  • 33
  • 1
  • 1
  • 10

0 Answers0