为什么 Logcat 在 Android studio 中的输出在两个相似的情况下不同?
Why is Logcat output in Android studio different in two similar cases?
为什么在以下情况下输出不同?
public void onResponse(Call call, Response response){
//first line...
Log.i("Body", "" + (response.body().toString()));
String mMessage = response.body().string();
//second line
Log.i("Message", "" + mMessage);
}
我有两个不同的 Logcat 输出
I/Body: okhttp3.internal.http.RealResponseBody@387ce26
I/Message{"name":"mohamed3@gmail.com","email":"mohamed3@gmail.com","type":"1","msg":"sucessfully"}
有什么解释吗?
response.body().toString()
是对 instanceof
String
-
的 引用
而 response.body().string()
正在获取它的 String
值。
为什么在以下情况下输出不同?
public void onResponse(Call call, Response response){
//first line...
Log.i("Body", "" + (response.body().toString()));
String mMessage = response.body().string();
//second line
Log.i("Message", "" + mMessage);
}
我有两个不同的 Logcat 输出
I/Body: okhttp3.internal.http.RealResponseBody@387ce26 I/Message{"name":"mohamed3@gmail.com","email":"mohamed3@gmail.com","type":"1","msg":"sucessfully"}
有什么解释吗?
response.body().toString()
是对 instanceof
String
-
而 response.body().string()
正在获取它的 String
值。