Try this instead:
while (contentItr.hasNext()) {
String word = (String) contentItr.next();
if (wordIndex.containsKey(word)) {
LinkedList temp = (LinkedList) w.get(word);
temp.addLast(currentUrl);
} else {
LinkedList temp = new LinkedList();
temp.add(currentUrl);
w.put(word, temp);
}
}
, , , Map - add , Map. , Map - LinkedList.
, . ( , ), , - :
Map<String, String> wordIndex = new HashMap<String, String>();
Map<String, LinkedList<String>> w = new HashMap<String, LinkedList<String>>();
List<String> content = new ArrayList<String>();
Iterator<String> contentItr = content.iterator();
, , , :
while (contentItr.hasNext()) {
String word = contentItr.next();
if (wordIndex.containsKey(word)) {
LinkedList<String> temp = w.get(word);
temp.addLast(currentUrl);
} else {
LinkedList<String> temp = new LinkedList<String>();
temp.add(currentUrl);
w.put(word, temp);
}
}
- LinkedList ArrayList ( ) LinkedList - , , - addLast ( add), - :
Map<String, String> wordIndex = new HashMap<String, String>();
Map<String, List<String>> w = new HashMap<String, List<String>>();
List<String> content = new ArrayList<String>();
Iterator<String> contentItr = content.iterator();
while (contentItr.hasNext()) {
String word = contentItr.next();
if (wordIndex.containsKey(word)) {
List<String> temp = w.get(word);
temp.add(currentUrl);
} else {
List<String> temp = new ArrayList<String>();
temp.add(currentUrl);
w.put(word, temp);
}
}