枚举中的儿童

发布于 2024-09-03 05:46:59 字数 455 浏览 1 评论 0原文

我有 JTree 中元素的枚举

当我在此 JTree 中找到某个特定元素时,我想检查它的子元素。枚举中的方法 children() 是否也检查它的孙子?

例如,我们假设这个 JTree,将标识视为树的新级别:

  • Fruits
    • 苹果
    • 葡萄
      • 橙色
      • 桃子
        • 菠萝
      • 草莓
    • 香蕉

如果我得到葡萄的孩子,我会只有橙子桃子草莓 strong> 还是我也会得到桃子孩子(菠萝)?

I have a enumeration for elements in a JTree

When I find some specific element in this JTree, I want to check it's children. Do the method children() in a Enumeration check it's grandcildren too?

For example, let's supose this JTree, considering the identation as new levels of the tree:

  • Fruits
    • apple
    • grape
      • orange
      • peach
        • pineapple
      • strawberry
    • banana

If I get the children of grape, will I have just orange, peach and strawberry or will I get peach children (pineaple) too?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

人间不值得 2024-09-10 05:46:59

你只会得到橙子、桃子和草莓。作为旁注以供将来参考,这种行为几乎是事实。

You would just get orange, peach and strawberry. As a side note for future reference, this kind of behavior is almost a de facto.

铁憨憨 2024-09-10 05:46:59

您将只有橙色和桃子 - 您需要检查它们的子节点(原始节点的孙子节点)。


编辑:正如推导所述,您还将获得草莓,因为它是第一级子级 - 但孙子级不会包含在枚举中。

You will just have orange and peach - you would need to check them for their children (grandchildren of the original node).


Edit: As derivation noted, you will also get Strawberry as that is a first level child - but the grandchildren will not be included in the enumeration.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文