title: Is there any null free list data structure?
body: <p>I am using <code>LinkedList</code> data structure <code>serverList</code> to store the elements in it. As of now, it can also insert <code>null</code> in the LinkedList <code>serverList</code> which is not what I want. Is there any other data structure which I can use which will not add null element in the <code>serverList</code> list but maintain the insert ordering?</p>
  
  <pre><code>    public List&lt;String&gt; getServerNames(ProcessData dataHolder) {
          // some code
  
          String localIP = getLocalIP(localPath, clientId);
          String localAddress = getLocalAddress(localPath, clientId);
  
          // some code
  
          List&lt;String&gt; serverList = new LinkedList&lt;String&gt;();
  
          serverList.add(localIP);
          if (ppFlag) {
              serverList.add(localAddress);
          }
          if (etrFlag) {
              for (String remotePath : holderPath) {
                  String remoteIP = getRemoteIP(remotePath, clientId);
                  String remoteAddress = getRemoteAddress(remotePath, clientId);
                  serverList.add(remoteIP);
                  if (ppFlag) {
                      serverList.add(remoteAddress);
                  }
              }
          }
  
          return serverList;
      }
  </code></pre>
  
  <p>This method will return a List which I am iterating it in a for loop in normal way. I can have empty <code>serverList</code> if everything is null, instead of having four null values in my list. In my above code, <code>getLocalIP</code>, <code>getLocalAddress</code>, <code>getRemoteIP</code> and <code>getRemoteAddress</code> can return null and then it will add null  element in the linked list. I know I can add a if check but then I need to add if check four time just before adding to Linked List. Is there any better data structure which I can use here?</p>
  
  <p>One constraint I have is - This library is use under very heavy load so this code has to be fast since it will be called multiple times.</p>