How I can get key, value pair from LinkedHashMap iterator?

I test SnakeYAML library to read .yaml documents. I have read Example 2.27. Invoice from and I get object: System.out.println(content); Yaml yaml = new Yaml(); Object o = yaml.load(content); where content is String loaded from file using Files.readAllBytes, encoding.decode (encoding is StandardCharsets.UTF_8) Reflection gaves me that o is type of java.util.LinkedHashMap and I can iterate over them: Set entrySet = o.entrySet(); Iterator it = entrySet.iterator(); System.out.println("LinkedHashMap entries : "); while (it.hasNext()) { Object entry =; System.out.println(entry); } Reflection return that type of entry is LinkedHashMap$Entry. But is **problem**: internal class LinkedHashMap$Entry is private and I can't declare objects this type. How I can get pair from entry, iterator or entrSet?
Use the public interface instead.

以上就是How I can get key, value pair from LinkedHashMap iterator?的详细内容,更多请关注web前端其它相关文章!

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

评论 抢沙发

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

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