实现:
根据需要实现返回类型是HashMap<String,Object> 或者TreeMap<String,Object>
// 方法 当传入是HashMap<String,Object>时,返回HashMap<String,Object>;当传入是TreeMap<String,Object>时,返回TreeMap<String,Object> public static <T extends Map<String,Object>> T
createSignMap(T params,String token,String orderNo){
params.put("token", token); params.put("orderNo", orderNo); return params;
}
// 调用:返回HashMap<String,Object>
HashMap<String,Object> transMap = new HashMap<String,Object>();
transMap = createSignMap(transMap,token,orderNo,);
上面版本提示:Variable is already assigned to this value [变量已分配给该值]
警告敏感:
// 方法 当传入是HashMap<String,Object>时,返回HashMap<String,Object>;当传入是TreeMap<String,Object>时,返回TreeMap<String,Object>
public static <T extends Map<String,Object>> T
createSignMap(T params,String token,String orderNo){
params.put("token", token);
params.put("orderNo", orderNo);
return params;
}
// 调用:返回HashMap<String,Object>
HashMap<String,Object> transMap = new HashMap<String,Object>();
createSignMap(transMap,token,orderNo,);