怪我咯2017-04-18 10:15:08
1. There is no class corresponding to an array in Java. Arrays are part of the Java language.
2. Data is a special object, which itself implements Cloneable
. There is a sentence in the javadoc of Object
's clone
method: Note that all arrays are considered to implement the interface Cloneable, so arrays can be used directly< code>clone method. Cloneable
。Object
的clone
方法的javadoc中有这么一句Note that all arrays are considered to implement the interface Cloneable ,所以数组是可以直接使用clone
方法的。
3、数组对象天生就有一个final
的length
3. The array object inherently has a final
length
attribute. Because the array is not defined in any class, there is no source code.
PHP中文网2017-04-18 10:15:08
Java’s array is just an array, and there is no class corresponding to it.
Clone() used in arrays does not have to be a class. As long as the compiler provides this syntax, it can be implemented.
Similarly, the length of the array is also an array attribute parsed by the compiler. It is not implemented by Java, and naturally the source code of Java cannot be seen.
ringa_lee2017-04-18 10:15:08
Class c = int[].class;
System.out.println(c.getPackage());
System.out.println(c.getName());
System.out.println(Modifier.toString(c .getModifiers()));
It can be understood like this:
Array class is a set of special classes, dynamically generated by the JVM runtime, including its length attribute and other method implementations
In addition to int[], boolean[] such arrays,
also includes user-defined Arrays of defined types, such as arrays in the format of com.yourPackage.YourClass[], as well as 2-dimensional, 3-dimensional, and multi-dimensional arrays
There is an interesting input result
The modifier of the int[] class is public abstract final
This is beyond our knowledge