of course the compiler complains that both puts have the same erasure and thus signature. Is something like this possible in Java? I would rather not make two methods "putT1(...)" "putT2(...)" since that would confuse things. Overloading by return type would also be great (for get() methods)... but I am pretty sure that is impossible in Java.
(I need this "double map" to ensure that the maps vary together in a specific way when one or the other is changed).
That actually won't work either since you can't determine what type you got (at runtime) and then put that type the appropriate map. I.e., I can't do
Hmmm.... you're absolutely correct. Without the instanceof operator, it isn't possible to determine the type. I figured out a way of avoiding the need for the operator -- by using maps of maps.... but even in that case, I couldn't avoid a typecast.
And regardless, this doesn't solve your problem of restricting it to only two types.
Anyway, in case you are interested.... here is my (somewhat broken) solution...