java array数组是不是类

来源:互联网 发布:sql语句多表关联查询 编辑:程序博客网 时间:2024/05/17 22:31

参考oracle官网:https://docs.oracle.com/javase/tutorial/reflect/special/array.html

Arrays

An array is an object of reference type which contains a fixed number of components of the same type; the length of an array is immutable. Creating an instance of an array requires knowledge of the length and component type. Each component may be a primitive type (e.g. byteint, or double), a reference type (e.g. StringObject, or java.nio.CharBuffer), or an array. Multi-dimensional arrays are really just arrays which contain components of array type.

Arrays are implemented in the Java virtual machine. The only methods on arrays are those inherited from Object. The length of an array is not part of its type; arrays have a length field which is accessible viajava.lang.reflect.Array.getLength().

Reflection provides methods for accessing array types and array component types, creating new arrays, and retrieving and setting array component values. The following sections include examples of common operations on arrays:

  • Identifying Array Types describes how to determine if a class member is a field of array type
  • Creating New Arrays illustrates how to create new instances of arrays with simple and complex component types
  • Getting and Setting Arrays and Their Components shows how to access fields of type array and individually access array elements
  • Troubleshooting covers common errors and programming misconceptions

All of these operations are supported via static methods in java.lang.reflect.Array.

翻译:

数组是一个引用类型的对象,它包含一个固定数量的相同类型的组件,数组的长度是不可变的。创建一个数组的实例需要了解长度和组件类型。每个部件可以是基元类型(如 byte,int或者double),引用类型(如String,object,或Java NIO CharBuffer。。),或者是一个数组。多维数组实际上是一个包含数组类型的数组的数组。


数组在虚拟机中实现。数组上唯一的方法是从对象继承。数组的长度不是类型的一部分;阵列的长度字段是可以通过Java.reflect.getlength()得到。


Reflection 提供了访问数组类型和数组组件类型、创建新数组、以及检索和设置数组组件值的方法。下面的部分包括数组的一般操作实例:
识别数组类型 描述了如何确定一个类成员是数组类型的字段
创建新的数组 说明了如何用简单和复杂的组件类型创建数组的新实例
获取和设置数组及其组件 显示了如何访问类型数组和单独访问数组元素的字段
故障排除 囊括常见的错误和编程错误
所有这些操作都是通过在静态方法java.lang.reflect.array支持。

结论:数组是一个类,他的方法是通过java.lang.reflect.array实现的。



0 0
原创粉丝点击