Keeps map keys as text whatever key type the signature declares
All 2 scenarios hold
The generic signature of a List, Set, or Map parameter decides what its elements become. The same cell text converts to a different type according to the element type the test method declares.
Every table below reads the same way. It holds one input column per collection kind, all three carrying the same values. Then it holds the element type the method received, and the elements themselves, which the input columns must convert to.
The method signature fixes an element type, and no row can vary it. Each element type therefore gets its own table.
Only a Map's value type takes part in conversion. Its keys are always the cell text, whatever key type the signature declares.
This table declares the parameter Map<Integer, Integer>. Its keys still arrive as the cell text, because only the value type takes part in conversion.
| Scenario | Map input | Key type? | Keys? | Value type? | Values? |
|---|---|---|---|---|---|
| Digits as keys |
| java.lang.String |
| java.lang.Integer |
|
| Words as keys |
| java.lang.String |
| java.lang.Integer |
|