java 数组是对象

Java中,每种数组类型都有对应的类,如int[]对应一个类。数组的直接超类是Object,它们实现了Cloneable和Serializable接口。数组是对象,可以动态创建并赋值给Object类型的变量。这段代码展示了如何创建一个int数组,并通过clone()方法复制它。
摘要由CSDN通过智能技术生成

In Java, there is a class for every array type, so there’s a class for int[] and similarly for float, double etc.
The direct superclass of an array type is Object. Every array type implements the interfaces Cloneable and java.io.Serializable.
In the Java programming language, arrays are objects (§4.3.1), are dynamically created, and may be assigned to variables of type Object (§4.3.2). All methods of class Object may be invoked on an array.

public static void main(String[] args)
    {
        int[] x = new int[3];
        int[] clone = x.clone();
        System.out.println(x.getClass().getName());

    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值