如何将Arraylist <arraylist <objects>转换为ArrayList <objects>

时间:2018-10-10 09:22:26

标签: java list arraylist

我将进一步阐述我的问题。 我有一个ArrayList<ArrayList<VehicleLoaded>>,其中VehicleLoaded是一个带有多个参数的类。 我想将所有那些VehicleLoaded都放在一个ArrayList中,有没有一种方法来获取它?

例如:我有这个:

[
1:[VehicleLoaded100, VehicleLoaded200, VehicleLoaded300,VehicleLoaded400],
2:[VehicleLoaded104,VehicleLoaded205,VehicleLoaded301],
3:[VehicleLoaded650, VehicleLoaded890,VehicleLoaded103]
…
]

我想要这个:

[VehicleLoaded100, VehicleLoaded200, VehicleLoaded300,VehicleLoaded400,
VehicleLoaded104,VehicleLoaded205,VehicleLoaded301,
VehicleLoaded650, VehicleLoaded890,VehicleLoaded103]

非常感谢您。

1 个答案:

答案 0 :(得分:10)

您可以使用{% for current in machine.Currency %} {% if date(current.Date) >= date(date1) and date(current.Date) <= date(date2) and date(current.Hour) >= date(hour1) and date(current.Hour)<= date(hour2) %} {% if current.Value < machine.Settings.workValue %} <div data-machine='{{machine.Id}}' {%if current.Comment%} comment-header='{{current.Comment.Header}}' comment-body="{{current.Comment.Comment}}"{%endif %} group-hier={{i}} data-value='{{current.Value}}' measure-date='{{current.Date}}' measure-hour='{{current.Hour}}' class="stopMachine progress-bar progress-bar-striped progress-bar-animated bg-warning bar" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100" ></div> {% set i = i + 1 %} {% else %} {% set i = 0 %} <div class="progress-bar progress-bar-striped progress-bar-animated bg-success bar" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100" ></div><hr /> {% endif %} {% endif %} {% endfor %} 来做到这一点:

Stream