class ParentItem {
String itemName; //I want to get this property for all the objects in hierarchy
Integer itemCode;
List<ParentItem> childItem;
}
Run Code Online (Sandbox Code Playgroud)
我想使用流获取所有项目的名称(ParentItem 名称、ChildItem 名称、GrandChildItemName),如何实现?假设 ChildItem 也有一个 Child,这意味着 ParentItem 有一个 GrandChild!所以嵌套有 3 层。如何实现这一目标?