在我的生活中,我无法弄清楚为什么SpeedTest中我的代码的这一特定部分无法正常工作。什么都没打印。我确信问题出在我使用的第一个foreach循环中,导致它永远不会停止运行或类似的东西。我想知道是否有人可以指出如何解决我的问题,以帮助它实际运行和打印。
以下是我遇到问题的SpeedTest的具体部分。
List<String> words = fp.getAllWords();
Date startTime1 = new Date();
// For each word, store in the hashTable how many times it appeared
System.out.println("test"); //my problem is that "test" prints but nothing after prints
for (String word : words) {
String a = word;
if (theHashTable.get(a) != null) { // if node not null, then a word has been recorded
int ind = theHashTable.get(a);
theHashTable.put(a, ind);
} else {
theHashTable.put(a, 1); // no such word has been recorded yet
}
}
Date endTime1 = new Date();
System.out.println("Time to add all words in script: "+ (endTime1.getTime()-
startTime1.getTime()));
感谢。