我有以下代码,我想将结果插入数据库但是现在我只想打印出带有值的键.
在此代码之前使用键设置HashMap,它可以正常工作.
下面的代码循环遍历tableView,从列中获取项,如果项等于哈希映射中的键,则它将dogsID作为值放入hashmap中.
// loop through tableView items
for (Dog item : BookDogTableView.getItems()) {
// cell data is not null
if ((BookDogSelectRunCol.getCellData(item) != null)) {
// loop through map
for (Integer key : hashMap.keySet()) {
// if chosen run ID equals key
if (BookDogSelectRunCol.getCellData(item)) {
// put dog in map
BookingInformation.hashMap.put(key,
item.getDogID());
}
}
}
for (Integer keyprint : hashMap.keySet()) {
if (hashMap.get(keyprint) != 0) {
System.out.println("RUn ID : " + keyprint + " DogID : "
+ hashMap.get(keyprint));
} …Run Code Online (Sandbox Code Playgroud) java ×1