124,374 views
16 votes
16 votes
SOMEONE HELP ME!!!!!

public class WordCounts extends ConsoleProgram
{
public void run()
{
HashMap h = new HashMap ();
String input = readLine("Enter a string: ");
String[] words = input.split(" ");
for(int i=0; i wordCount){
// Sort all the keys (words) in the HashMap
Object[] keys = wordCount.keySet().toArray();
Arrays.sort(keys);

// Print out each word and it's associated count
for (Object word : keys) {
int val = wordCount.get(word);
System.out.println(word + ": " + val);
}
}
}
I can't fix this. these are the errors
WordCounts.java:30: error: cannot find symbol
private void printSortedHashMap(HashMap wordCount){
^
symbol: class HashMap
location: class WordCounts
WordCounts.java:5: error: cannot find symbol
HashMap h = new HashMap ();
^
symbol: class HashMap
location: class WordCounts
WordCounts.java:5: error: cannot find symbol
HashMap h = new HashMap ();
^
symbol: class HashMap
location: class WordCounts
WordCounts.java:33: error: cannot find symbol
Arrays.sort(keys);
^
symbol: variable Arrays
location: class WordCounts
4 errors

User Blablablaster
by
2.8k points

1 Answer

7 votes
7 votes

Answer:

I don't see the question

Step-by-step explanation:

User Jay Anderson
by
2.9k points