【发布时间】:2013-08-21 20:57:58
【问题描述】:
如何解决这个问题?
类型安全:mResponseValue 类型的表达式需要未经检查的转换才能符合mResponseValue<mUserStatus>
mResponseValue<mUserStatus> ResponseValue = Mobile.JSONtoClass(responseService, mResponseValue.class);
public abstract class Mobile {
public static String ObjToJson(Object obj)
{
Gson gson = new Gson();
return gson.toJson(obj);
}
public static <T> T JSONtoClass(String strRequest,Class<T> type)
{
Gson gson = new Gson();
return gson.fromJson(strRequest, type);
}
}
【问题讨论】:
-
使用通配符应该可以。
标签: java