cast LinkedHashMap to HashMap in groovy

How do I convert `LinkedHashMap` to `java.util.HashMap` in groovy? When I create something like this in groovy, it automatically creates a `LinkedHashMap` even when I declare it like `HashMap h = ....` or `def HashMap h = ...` I tried doing: HashMap h = ["key1":["val1", "val2"], "key2":["val3"]] and def HashMap h = ["key1":["val1", "val2"], "key2":["val3"]] `h.getClass().getName()` still comes back with `LinkedHashMap`.
Just curious, why do you care what implementation of Map it's creating?

以上就是cast LinkedHashMap to HashMap in groovy的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准