Due to the peculiarities of Integer (which the LinkedList needs to return for null) and Int, your second suggestion doesn't compile without an explicit type cast. I thought this ended up making it a little less pretty than your first suggestion, so I just went with that.