无法将String类型转换为Object类型?

时间:2014-07-03 04:23:24

标签: java android

  

将对象类型转换为String?

e.g。 :方法getResponse()返回类的对象类型

请求。

String s1=(String)req.getResponse();

1 个答案:

答案 0 :(得分:6)

  

将对象类型转换为String?

简而言之,不要。但是,您可以拨打toString()

String s1 = req.getResponse().toString(); // <-- which may or may not be a useful
                                          // operation. If response doesn't override
                                          // toString() this will just return a class 
                                          // name and a hashcode.
相关问题