为int []一个对象? [英] Is int[] an object?

查看:119
本文介绍了为int []一个对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一看,我似乎无法找到一个问题,是与此相同。我的问题是关于 INT [] Java编写的。

Had a look, and I can't seem to find a question that is the same as this. My question is about int[] in Java.

当你创建一个 INT [] ,您可以使用此语法:

When you create an int[], you use this syntax:

int[] x = new int[5];

这是一部分的方法 INT [] 也让我觉得这是一个对象,但它不 ŧ遵循类的Java命名约定,这是什么的困惑我。它也是一个原始类型,它可以像一个原语被用来阵列

The methods that are part of int[] also make me think it's an Object, but it doesn't follow the Java naming convention for classes, which is what's confusing me. It is also an array of a primitive type, which can be used like a primitive.

INT [] (或任何基本数组我猜的)一个对象或原始?

Is an int[] (or any primitive array I guess) an object, or a primitive?

推荐答案

在Java中的数组是对象,因此它是一个对象类的子类 - 即使它包含基本类型。您可以检查这一点:

An array in Java is a subclass of Object, therefore it's an object type - even if it contains primitive types. You can check this:

int[] x = new int[5];
if (x instanceof Object)
    System.out.println("It's an Object!");

这篇关于为int []一个对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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