If someone would be so kind as to fix my code for me and explain where I'm going wrong, I'd greatly appreciate it.
thanks,
irongleet
import java.io.*;
import java.util.*;
public class AscendingOrder {
public static void main(String[] args) throws IOException {
ObjectInputStream input = new ObjectInputStream(new FileInputStream("words.txt"));
Map<String, Integer> hashMap = new HashMap<String, Integer>();
// code to read the words in the text file into the hashMap
hashMap.put(input.readObject(), 1);
hashMap.put(input.readUTF(), 2);
hashMap.put(input.readUTF(), 3);
hashMap.put(input.readUTF(), 4);
input.close();
Map<String, Integer> treeMap = new TreeMap<String, Integer>(hashMap);
System.out.println("Display entries in ascending order of key");
System.out.println(treeMap + "\n");
}
}

New Topic/Question
Reply




MultiQuote








|