ItelliJ IDEA调试时,变量窗口那个@是什么意思,看着也不像内存地址

HackerDotCn 2017-09-11 05:51:30


不管数据类型是int还是long,都是按顺序排列的,显然不是内存啊,那代表啥意思
...全文
2795 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
码届小王 2020-07-23
  • 打赏
  • 举报
回复 2
https://blog.csdn.net/baichoufei90/article/details/84102509
给分吧
码届小王 2020-07-23
  • 打赏
  • 举报
回复
顶个,期待结贴
汪振兴 2018-12-26
  • 打赏
  • 举报
回复
变量窗口怎么关闭?
miaoch 2018-08-06
  • 打赏
  • 举报
回复
引用 2 楼 hardycheng 的回复:
不是内存地址,
···
toString
public String toString()
Returns a string representation of the object. In general, the 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.
The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', 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:

getClass().getName() + '@' + Integer.toHexString(hashCode())

Returns:
a string representation of the object.

···
这个就是对象的toString, 那个数字是hashcode

参考
https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#toString()

我觉得你说错了,因为Integer的toString明显不是Integer@xxx 因为人家已经重写这个方法了。
另外,你看看那个图,xxx如果是hashcode生成的,能那么整齐有序吗。
我觉得这个Integer@xxx 更像是这个ide的一个展示方式
hardycheng 2018-08-03
  • 打赏
  • 举报
回复
不是内存地址,
···
toString
public String toString()
Returns a string representation of the object. In general, the 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.
The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', 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:

getClass().getName() + '@' + Integer.toHexString(hashCode())

Returns:
a string representation of the object.

···
这个就是对象的toString, 那个数字是hashcode

参考
https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#toString()
老dong 2018-07-26
  • 打赏
  • 举报
回复
@XXX;就是变量的相对内存地址;你可以把这段代码调试一下;看看a和b他们的内存相对地址是不一样的;而aa和bb因为是引用的同一个常量池中的同一内存地址的值;所以equals

1 public class test1 {
2 public static void main(String[] args) {
3 String a = new String("ab"); // a 为一个引用
4 String b = new String("ab"); // b为另一个引用,对象的内容一样
5 String aa = "ab"; // 放在常量池中
6 String bb = "ab"; // 从常量池中查找
7 if (aa == bb) // true
8 System.out.println("aa.equals(bb)");
9 if (a == b) // false,非同一对象
10 System.out.println("a==b");
11 if (a.equals(b)) // true
12 System.out.println("a.equals(b)");
13 if (42 == 42.0) { // true
14 System.out.println("true");
15 }
16 }
17 }

62,628

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧