Shaving off some lines :-)
boolean equal = true;
while (iterator.hasNext() && linkedListIterator.hasNext() && equal) {
equal = iterator.next().equals(linkedListIterator.next());
}
Martijn
On Tue, Sep 1, 2009 at 12:47 PM, Todd Volkert<[email protected]> wrote:
> I personally don't have a problem with it, but if some find it hard to read,
> then here's the same thing re-phrased:
>
> #!{{{
> boolean equal = true;
>
> while (iterator.hasNext()
> && linkedListIterator.hasNext()) {
> if (!iterator.next().equals(linkedListIterator.next())) {
> equal = false;
> break;
> }
> }
>
> return equal;
> }}}
>
> I prefer the brevity of the former, but that may just be me :)
>
> Cheers,
> -T
>
> On Tue, Sep 1, 2009 at 6:38 AM, Martijn Dashorst <[email protected]
>> wrote:
>
>> On Tue, Sep 1, 2009 at 11:41 AM, Noel Grandin<[email protected]>
>> wrote:
>> >
>> > It's legal and technically correct Java, but I prefer to write such
>> > things like this:
>> >
>> > while (iterator.hasNext()) {}
>> >
>> > to make it obvious that it's an empty block.
>> >
>>
>> And even better:
>>
>> while (iterator.hasNext()) { /* intentionally left blank */ }
>>
>> But this type of code does smell pretty awful and should be avoided in
>> the first place.
>>
>> Martijn
>>
>
--
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.4 increases type safety for web applications
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.4.0