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 directlyclone method. Cloneable。Object的clone方法的javadoc中有这么一句Note that all arrays are considered to implement the interface Cloneable ,所以数组是可以直接使用clone方法的。 3、数组对象天生就有一个final的length3. The array object inherently has a finallength attribute. Because the array is not defined in any class, there is no source code.
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.
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
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 ofObject
'sclone
method: Note that all arrays are considered to implement the interface Cloneable, so arrays can be used directlyclone 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 afinal
length
attribute. Because the array is not defined in any class, there is no source code.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.
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