列表清单 [英] List of Lists of Lists

查看:95
本文介绍了列表清单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Java的新手,我需要列出一系列列表。我可以在python中做到这一点,因为列表的元素可以是一个列表,所以在嵌入列表中 list [0] 将引用一个列表并且 list [0] [0] 将引用嵌入列表的zeroeth元素。有没有简单的方法在java中实现这种行为?

I'm new to Java and I need to make a list of lists of lists. I could do it in python because an element of a list can be a list so in an embedded list list[0] would refer to a list and list[0][0] would refer to the zeroeth element of the embedded list. Is there any easy way to implement this behavior in java?

推荐答案

所有其他答案在技术上都是正确的,但恕我直言,如果你实施列表列表的粗略列表,您没有在适当的抽象级别处理您的数据。例如,我很确定列表列表在您的业务领域中已经意味着某些东西。将这个东西封装在另一个对象中,这样你就可以得到一个List< Something>而不是难以使用和维护List< List< List< Object>>>。

All the other answers are technically correct, but IMHO if you implement a rough List of Lists of Lists you are not treating your data at the right level of abstraction. For example I am pretty sure that a List of Lists already means "something" in your business domain. Encapsulate this "something" in another object so you can just have a List<Something> instead of a difficult to use and maintain List<List<List<Object>>>.

这篇关于列表清单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆