对象内存地址的获取以及关于System 类

本文通过示例代码展示了如何获取Java中对象的内存地址,并深入探讨了System类的功能及用途,包括标准输入输出、属性访问、文件加载等。

对象内存地址的获取以及关于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 类提供的设施中,有标准输入、标准输出和错误输出流;对外部定义的属性和环境变量的访问;加载文件和库的方法;还有快速复制数组的一部分的实用方法。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值