我正在編寫一個程序來根據modvalue對數據庫進行分區。爲此,我使用一個列表(listoflists
),它將包含一個分區的一個列表。但是當我運行這個時,列表的內容沒有顯示,或者數據沒有被添加到列表中。
下面是代碼:無法顯示列表/數據的內容未添加到列表
//List of lists
List<List<Integer>> listoflists = new ArrayList<List<Integer>>();
while(rs.next()) {
int rollno = rs.getInt(1);
data = Integer.toString(rollno);
//calculating hmac value
int hmacvalue = dbpartition.hmacSha1(data, ks);
modvalue = Math.abs(hmacvalue % wl);
System.out.println("modvalue is " + modvalue);
for(int i = 1; i <= wl; i++)
{
List<Integer> list = new ArrayList<Integer>();
//System.out.println("List created");
if(i == modvalue)
{
list.add(rollno);
System.out.println("data added to List");
}
}
}
System.out.println(listoflists);
而且我得到的輸出是:
The hash of the tuple is 37529665
modvalue is 4
data added to List
The hash of the tuple is -1387128724
modvalue is 7
data added to List
The hash of the tuple is 636638561
modvalue is 0
The hash of the tuple is 435523502
modvalue is 11
data added to List
[]
誰能告訴我在哪裏,我錯了?
你似乎沒有添加'list'(我認爲)'Listoflists' ... – MadProgrammer