Home  >  Q&A  >  body text

java - 请教前辈们关于枚举值如何一对多关联额?

迷茫迷茫2712 days ago599

reply all(3)I'll reply

  • PHPz

    PHPz2017-04-17 16:48:34

    Use enumeration? ? If the business is simple, it is recommended to use map to construct the index yourself. If the business is complex, you can use a graph database such as neo4j

    reply
    0
  • 黄舟

    黄舟2017-04-17 16:48:34

    Java’s enumeration is not only a simple function, but also very scalable. According to your requirements, write an example for you to see:

    enum Country {
        CN ("北京", "上海", "广州", "深圳"),
        US ("华盛顿", "洛杉矶")
        ;
        public final String[] cities;
        
        public Country(String... cities) {
            this.cities = cities;
        }
    }

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 16:48:34

    In C language, for example, use 16-bit unsigned int to represent
    0xabcd. The first two digits represent the country and the last two digits are the city. Do bit operations
    0x0100 ~ 0x01ff China
    0x0200 ~ 0x02ff United States

    reply
    0
  • Cancelreply