At a quick glance, I see three bugs. There may be more.
- Instead of
l != null || l != f
, I'm pretty sure you want&&
- the condition as you've written it is always true. - You should use
{}
to delimit the "true" branch of yourif
. Currently,this.add(insert);
andbreak;
will run whether theif
condition is true or false - and your indentation suggests that this isn't what you're expecting. - In
this.add(insert)
, you're not specifying where in the list to add the new node. I would expect to see something that specifies you'll be adding it at the position indicated byl
.