log.d("FirstActivity",this.toString()) 求问大神这个语句是什么意思呀?this.toString() 是什么意思?
第1个回答 2017-08-21
我建议你,ctrl+点击查看该方法源码,虽然里边的解释是英文,但是大多数情况还是能看得懂的。
首先看到this,指的肯定是当前的活动等,Activity的toString方法官方给的解释如下:
/**
* Returns a string representation of the object. In general, the
* {@code toString} method returns a string that
* "textually represents" this object. The result should
* be a concise but informative representation that is easy for a
* person to read.
* It is recommended that all subclasses override this method.
* <p>
* The {@code toString} method for class {@code Object}
* returns a string consisting of the name of the class of which the
* object is an instance, the at-sign character `{@code @}', and
* the unsigned hexadecimal representation of the hash code of the
* object. In other words, this method returns a string equal to the
* value of:
* <blockquote>
* <pre>
* getClass().getName() + '@' + Integer.toHexString(hashCode())
* </pre></blockquote>
*
* @return a string representation of the object.
*/
public String toString() {
return getClass().getName() + "@" + Integer.toHexString(hashCode());
}
从简介和方法的内容我们就可以大致的理解到,返回的是当前Activity的name+“@”+当前object的索引。本回答被提问者采纳
Warning: Invalid argument supplied for foreach() in /www/wwwroot/aolonic.com/skin/templets/default/contents.html on line 45
相似回答