You save a value by assigning it to a variable.
Type: Posts; User: Norm
You save a value by assigning it to a variable.
Where does the code save items from the list so they can be checked?
For example this line prints out an item without saving it for checking:
System.out.print("ID: [" + entry.getKey() + "] ...
Are the 3s adjacent to each other in the list? After outputting one item from the list can you check the next item for equality and skip outputting it if it matches the last item output?
Use...
It is working now?
Just talking about output for debugging purposes.
The point is raw data without an id String can be hard to associate with the variable that held it.
My entry printout: pE entry=cat=[2]
your printout: [2]
Your printout doesn't say what [2]...
It's useful when printing variables to add an ID String to identify what is printed:
System.out.println("wordMap="+wordMap);
...
System.out.println("pE entry="+entry); //<<<<<<<<< pE...
How can you get references to each of those objects so they can be compared?
What printed when you used println() calls to show the following:
What is in the collection: wordMap?
What is in the...
What objects are those in? You need object names to write code.
Use println() calls to show the following:
What is in the collection: wordMap?
What is in the object: entry? The code only prints...
What objects do you want to compare?
What is in the collection: wordMap?
What is in the object: entry? The code only prints part of it.
This code makes not sense:
if (!itr.equals(itr.next()))
The two objects being compared are probably of different types.
Print out the value of entry first thing in the printEntry() method to...
Continue debugging to see what is happening to the data.
Where is that iterator that has said that it had a next entry used in the printEntry() method?
There is a new iterator created in the printEntry() method. That is the one to test.
Add some...
Basically the code should call hasNext() before calling next()
Is there an element avaiable when the next() method is called on line 67? The code should test BEFORE calling next()
Does it compile, execute and work correctly?
I'm done for tonight. Back tomorrow.
The posted code doesn't check for duplicates before adding a number to the list.
lines.add(new Integer(lineNum));
Is it ok to have duplicate line numbers in the list?
Where does the code test for a duplicate entry?
Can you post the program's output that shows the problem, add some comments to the output describing what is wrong with it and show what it should be.