通过在Java中打印对象获得的信息的含义是什么? [英] What is the meaning of the information that I get by printing an Object in Java?

查看:153
本文介绍了通过在Java中打印对象获得的信息的含义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  Integer [] a = new Integer [5]; 
System.Out.println(((Object)a).toString());

输出得到的是

  [Integer @ 89fbe3 

89fbe3的含义是什么?这是一种什么样的地址?哈希码?每个对象都是独一无二的吗? ,如果是这样 - 如果它是一个多线程程序,它仍然是唯一的吗?



谢谢!

解决方案

这是对象的内存地址,这是默认的toString()在Object类中实现的内存地址。它也是默认的hashCode()。


Lets say i have this code :

Integer[] a= new Integer[5];
System.Out.println(((Object)a).toString());

the output is get is

[Integer@89fbe3

what is the meaning of 89fbe3 ? is this some kind of address ? hash code? is it unique for each object? , and if so- if its a multi-threaded program , is it still unique ?

thanks !

解决方案

It's the memory address of the object which is what the default toString() implemented in the Object class does. It is also the default hashCode().

这篇关于通过在Java中打印对象获得的信息的含义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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