枚举中的儿童
我有 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你只会得到橙子、桃子和草莓。作为旁注以供将来参考,这种行为几乎是事实。
You would just get orange, peach and strawberry. As a side note for future reference, this kind of behavior is almost a de facto.
您将只有橙色和桃子 - 您需要检查它们的子节点(原始节点的孙子节点)。
编辑:正如推导所述,您还将获得草莓,因为它是第一级子级 - 但孙子级不会包含在枚举中。
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.