为什么toString()返回一个十六进制的code? [英] Why toString() returns an hexadecimal code?

查看:211
本文介绍了为什么toString()返回一个十六进制的code?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是写在我的应用程序

  LastFmServer服务器= AndroidLastFmServerFactory.getServer();
艺术家[]的结果;
结果= server.searchForArtist(Hatebreed);
Log.e(,结果[2]的ToString());

为什么这个code使这个出现在logcat中?

  fm.last.api.Artist@2bf03488


解决方案

是因为那类没有实现其自身的toString,所以你最终调用继承自一个的java.lang.Object ,让你的类名和哈希。

I have this written in my app

LastFmServer server = AndroidLastFmServerFactory.getServer();
Artist[] results;
results = server.searchForArtist("Hatebreed"); 
Log.e("", results[2].toString());

Why does this code make this appear in logcat?

fm.last.api.Artist@2bf03488

解决方案

It's because that class doesn't implement its own toString, so you end up calling the one inherited from java.lang.Object that gives you the class name and its hash.

这篇关于为什么toString()返回一个十六进制的code?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆