There are three kinds of actuaries: those who can count, and those who can't.
There are three kinds of actuaries: those who can count, and those who can't.
There are three kinds of actuaries: those who can count, and those who can't.
Carey Brown wrote:LinearNode node = top;
int i;
for( i=0 ; i < count && ! ((element == null && node.element == null) || node.element.equals(element)) ; i++, node = node.getNext() )
;
if( i == count )
return -1;
else
return i;[/code]
There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:for( i=0 ; i < count && ! ((element == null && node.element == null) || node.element.equals(element)) ; i++, node = node.getNext() )
There are three kinds of actuaries: those who can count, and those who can't.
Congratulations. I'm glad this worked for you. If you really do have data with null in it you'll need to incorporate Paul's suggestion.Constantin Cornea wrote:Finally, the only change that I did is just node.getElement() as you can see below :
I think you should go one further: add a comment saying // empty statement or similar.Carey Brown wrote:. . . show that it's an empty statement. You could do the same thing (perhaps better) with an empty set of braces.