下面是我的Java方法列表中添加一次overwrting又一次
public static List<Match<String, String>> Decider
(List<Preference<String, String>> hospitalPrefs,List<Preference<String, String>> studentPrefs)
{
Match<String, String> matching = new Match<String, String>(null, null);
List<Match<String, String>> matcher = new ArrayList<Match<String, String>>();
/** Matching the preference of the hospital with the student */
for(int hospitalLoop = 0;hospitalLoop < hospitalPrefs.size(); hospitalLoop++)
{
String hospitalPreferrer = hospitalPrefs.get(hospitalLoop).getPreferrer();
String hospitalPreferred = hospitalPrefs.get(hospitalLoop).getPreferred();
int hospitalValue = hospitalPrefs.get(hospitalLoop).getValue();
for(int studentLoop = 0;studentLoop < studentPrefs.size();studentLoop++)
{
String studentPreferrer = studentPrefs.get(studentLoop).getPreferrer();
String studentPreferred = studentPrefs.get(studentLoop).getPreferred();
int studentValue = studentPrefs.get(studentLoop).getValue();
if(hospitalPreferred.equals(studentPreferrer)
&& hospitalPreferrer.equals(studentPreferred)
&& hospitalValue == studentValue)
{
System.out.println(hospitalPreferred + "," + studentPreferred);
matching.setItem1(hospitalPreferred);
matching.setItem2(studentPreferred);
matcher.add(matching);
break;
}
}
}
return matcher;
}
匹配变量是覆盖列表。我对此感到困惑。
有点像我加入
a,b,c。
在匹配变量是加 C,C,C
我很困惑,我要去错了。
谢谢!
(1)在哪里,你是如何检查的内容'matcher'? (2)'getItem1()'方法从哪里来? – 2013-04-09 20:57:43