Possible Duplicate:
How to determine the class of a generic type?
How to obtain class instance generic argument type
我有一套核心代码:
public static class ServiceLocator
{
private static Dictionary<Type, Type> services = new Dictionary<Type, Type>();
public static void RegisterService<T>(Type service)
{
services[typeof (T)] = service;
}
...
}
I want to write the same logic on java. How can I get type of generic T (T.getClass() not working)
like typeof (T)
in c#?