For our homework assignment, we have to write a program that reads integers from a specified file. If there are duplicate entries, we need to output them as well as they're locations. If not, we need to state that there aren't any duplicates. I've gotten most of the code below:
The program compiles fine, but when I run it, needless to say nothing outputs - there's no println. I have no clue how to actually print the results. Everytime I add a println I get a compiling error. What's the syntax for printing Hashmaps? HELP!!!
There are few things you should correct in your code. First look at the Scanner and see how you can pass a file name in to the scanner and remember by default the values should be delimited by white spases in the file for scanner to identify them. And HasMap has overriden toString() method when used in System.out.print(), prints the content of the HashMap.