This is not an index, this is a key. In a Map, you associate some values to some keys, and retrieve the values via the keys. In your example, you are using Integers for keys. These are not indexes, these are still keys.
1 -> "One"
2 -> "Two"
map.get(2) : "Two"
map.get(3) : null
IndexOutOfBoundsException will never be thrown, because this is not an index you are using. The value associated to 3 does not exist, so null is returned.
List are different. You can access elements via an index. This index ranges from 0 to the size of the list(excluded). If the index is out of this range, IndexOutOfBoundsException will be thrown.
Joined: Jun 01, 2010
EDIT: I posted this at the same time as Christophe Verré so this is probably redundant.
Lists are all about indexes. Maps are all about key-value pairs.
As Christophe Verré suggests, I think you are confusing indexes with keys. In Lists, you can have multiple null values. You also always know when an index is valid (0 to List.length - 1) so trying to access anything outside those indexes is considered a programming error. For maps, you don't always know the keys so asking for the corresponding value of a key is not considered a programming error and therefore returns null if the key does not exists in the map.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com