Accessing Java HashMap with Integer keys


In the following program, the first ‘puts’ works but the second ‘puts’
returns a nil. If I am accessing a java HashMap that has
java.lang.Integer keys, is there a simpler way to get values out of the
map than the h.get used with the first ‘puts’?

David B.

require “java”
include_class “java.util.HashMap”

h =
h.put(, “aaa”)
h.put(, “bbb”)

puts h.get( # => “aaa” … OK
puts h.get(1) # => nil … no go