There is no general answer to this question. The implementation of the linked list must already define the concept of a dummy node and use it consistently. A typical way to achieve this would be by declaring a special dummy instance:
public class Node {
public static final Object DUMMY = new Object();
...
and assigning middle.element = DUMMY;
As you can imagine, this will have no effect unless all the rest of the API implementation abides by this convention.
If your list is specified as unable to contain null
elements, then you could also assign middle.element = null
, but the rest of the story stays the same.