iterate through recursive objects

前端 未结 5 1584
孤独总比滥情好
孤独总比滥情好 2021-01-29 14:54

I am trying to iterate through a recursive object but Java has no support for this from what I know.

For example, given the object Item:

pub         


        
5条回答
  •  清歌不尽
    2021-01-29 15:37

    Something similar to this?

    void read(Item item) {
        if (item == null) {
            //do something with the uuid ?
            return;
        } else {
            for (Item i : item.children) {
                read(i);
            }
        }
    }
    

提交回复
热议问题