I'm not sure how you are using the word "previous" here, but if that's the opposite of "next" in the Iterator then...
If you have your dtos in a List (rather than just a Collection) then that implies a sequence for the members, and you can get a ListIterator rather than a simple Iterator. ListIterators allow both forward and backward traversal of the List.
JamesCherrill
... trying to help
8,534 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,456
Skill Endorsements: 30
@ritchieking: looks like you were distracted or something when you wrote that one!
The original code creates an Integer (nb spelling!) from the int parameter because its used as a key value in the Map, and Map keys can't be primitives. Modern Java versions will auto box/unbox to convert implicitly between int and Integer, but it cases like that it's helpful to keep it explicit.
dim = new Dim; Starting a method by overwriting a parameter's value is never going to be a good idea.
if(foo.equals("null")) this is in no possible way a substitute for if (foo == null) What were you thinking?
JamesCherrill
... trying to help
8,534 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,456
Skill Endorsements: 30
You really must update your Java.
JamesCherrill
... trying to help
8,534 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,456
Skill Endorsements: 30
Pseudo-code:
String previous = "";
loop through values {
if (value.equals(previous)) print on same line;
else start a new line;
previous = value;
}
JamesCherrill
... trying to help
8,534 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,456
Skill Endorsements: 30