Compare String with Null Object
<p>I have a very simple question that I am not able to understand how should I move further.</p>

<p>I have a doubly linked list in which First node is null object and Last node is null object.</p>

<p>And I have a various string element that I want to insert in between first and last node. For example- I have string element "C", "D", "A", "P".</p>

<p>And after inserting into doubly linked list. I need some insertion order like this-</p>

<p>FirstNullObject P D C A LastNullObject</p>

<p>So I am not sure how should I compare null object with the various string that I want to compare and keep on adding. Suppose firstly I am adding C then somehow I have to insert C in between those two null object. And then if I am adding D then I have to compare D with C and then list should like this-</p>

<p>FirstNullObject D C LastNullObject</p>

<p>here newLink is the newNode like C, D and firstNode is null object. but this doesn't works. I always get an exception.</p>

<pre><code>if (newLink.data.compareToIgnoreCase(list.firstNode.data) &gt; 0) {

        //logic

        }
</code></pre>

<p>I hope questions is clear</p>
