I encounter a problem that with Java, I have a map,such as map<K,V>
, K
and V
can be arbitrary type, e.g int
, Long
, String
, Time
, etc.
After the map is serialized, can I get the length of K
or the V
? Can I write a common method to implement this idea? Something like:
public long getLength(object obj) {
//how to get the length of this obj, obj can be any type
}
How could do that?