问题描述
我已经解析的HTML时间表和加载每一个问题我的类对象。
所以,我有我的学科ArrayList中有名字的信息,教师,...,小时,天
现在我想重建表,所以我需要先对其进行分类。我认为最是有结构是这样的:
I have parsed a HTML timetable and loaded every Subject to my class object.So i have arrayList of my Subjects which has information of name, teacher,... ,HOUR, and DAYnow i want to reconstruct the table and so I need to categorize it first. I think that best would be to have structure like this:
Monday: 1: Math, Czech, ...
2: History
...
Tuesday: 1: English, Geo
2...
...
可能有多个科目给出小时,所以我试图用Multimap之的Multimap之,但我在我不能宣布它我的解析。
There can be mutiple subjects in given hour, therefore I tried to used Multimap of Multimap, but I am not able to declare it during my for parsing.
Multimap<String, Multimap<String, Subject>> timetable = HashMultimap.create();
...
for ...
timetable.put(subject.den, new HashMultimap<>(subject.hod, subject));
但它说,HashMultimap设有私人accesin com.google.common ...
我不知道如何正确地写。我也想用数组,但我不得不pre-声明它,我想一个周期内建立这个。
有任何想法吗?谢谢你在前进
but it says that HashMultimap has private accesin com.google.common...I dont know how to correctly write this. I was also thinking about using Array, but I would have to pre-declare it and I would like to build this during one for cycle.Any ideas? Thank you in advance
推荐答案
它看起来像你想要的其实更多的地图&LT;弦乐,Multimap之&LT;弦乐,主题和GT;&GT;
,在这种情况下,你希望
It looks like what you want is actually more of a Map<String, Multimap<String, Subject>>
, in which case you want
Map<String, Multimap<String, Subject>> timetable = new HashMap<>();
for ...
Multimap<String, Subject> multimap = timetable.get(subject.den);
if (multimap == null) {
multimap = HashMultimap.create();
timetable.put(subject.den, multimap);
}
multimap.put(subject.hod, subject);
这篇关于Multimap之爪哇Multimap之 - 群归类时间表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!