对象内存地址的获取以及关于System 类
public class Address
{
static final Integer i1 = new Integer(5);
final Integer i2 = new Integer(15);
public static void main(String[] args)
{
String s1 = "what";
String s2 = "are";
System.out.println(Integer.toHexString(s1.hashCode()));
System.out.println(Integer.toHexString(s2.hashCode()));
System.out.println(Integer.toHexString(System.identityHashCode(s1)));
Address a = new Address();
Address b = new Address();
System.out.println(Integer.toHexString(System.identityHashCode(a.i1)));
System.out.println(Integer.toHexString(System.identityHashCode(b.i1)));
System.out.println(Integer.toHexString(System.identityHashCode(a.i2)));
System.out.println(Integer.toHexString(System.identityHashCode(b.i2)));
}
}
//////////////////////////////////////////////////////////////////////////////////////////
public final class System extends Object
System 类包含一些有用的类字段和方法。它不能被实例化。
在 System 类提供的设施中,有标准输入、标准输出和错误输出流;对外部定义的属性和环境变量的访问;加载文件和库的方法;还有快速复制数组的一部分的实用方法。
本文通过示例代码展示了如何获取Java中对象的内存地址,并深入探讨了System类的功能及用途,包括标准输入输出、属性访问、文件加载等。
2975

被折叠的 条评论
为什么被折叠?



