I use the following Code to do get an item from a LinkedList inside an Android Activity

```
    currentAlarm = alarmQueue.peek();

```

alarmQueue itself is created like that, inside a class that extends Application

```
public static Queue<Long> getAlarmQueue() {
    if (alarmQueue == null)
    {
        Log.d(TAG, "alarmqueue was null, creating new one");
        alarmQueue = new LinkedList<Long>();
    }
    return alarmQueue;
}

```

The app is in production status and released on google play, but sometimes there a error reports saying that the line containing .peek() throws an nullpointerexception. Therefore I added the null check you can see above, as I thought that alarmQueue itself was null.
Actually, after some tests, I realized that .peek() throws the nullpointerexception if the LinkedList does not contain any items.

I understand, that it may return null, but the doc doesn't say that it throws an exception
[Android Doc LinkedList](http://developer.android.com/reference/java/util/LinkedList.html#peek%28%29)

What am I missing here?
Thanks!

EDIT: Image proof for exception ![Image proof for exception](https://i.stack.imgur.com/5SPwC.png)
EDIT2: I found the cause.. What a terrible mistake... The type of currentAlarm was **l**ong not **L**ong, so the nullpointerexception was raised as long was the primitive data type and cannot take null as argument :/
However, this error should never happen, because at this point, there has to be something inside the queue, so I have to keep digging deeper. But for this error, everything is fine and error handling was added.