-1
我想给getMap
一个整数值超载,但地图只返回一个对象。无论如何要转换它?或者有类似于C++自动说明符的东西?如何对象转换为INT
public class EventMessage<T> {
private final Map<EventType, T> messageInput;
public EventMessage(EventType type, T t) {
messageInput = new HashMap<EventType, T>();
messageInput.put(type, t);
}
public Map<EventType, T> getMap(){
return messageInput;
}
public T getMap(EventType type){
return messageInput.get(type);
}
}
创建'事件消息'在你的代码,并使用整型。 –
'getMap'返回'T',如果你想让它返回'Integer',你应该实例化一个'事件消息' –