Yesterday, I was asked if the Java array is a class. The first response to this question is certainly yes, whether from the way Java arrays are defined or from object-oriented understanding. But think carefully, but it is not so.
According to the usual understanding, Java is a pure object-oriented language, so everything is object, for all types are objects or object variants. However, arrays and other data types are not generic objects. For example, the General object definition is this:
Myclass C1 = new Myclass ();
And the array definition is this:
int a[] = new INT[50];
This will see a problem when the array is declared without calling the constructor. The definition of an object in Java needs to call the constructor, and the array does not, which indicates that the array is not a class, or is not a simple class. A simple program has been written to test the correlation functions of arrays in Java.
You can also print examples of common classes and arrays of classes to see the results:
public class Test {public
static void Main (string[] args)
{
Test t1 = new test ();
Test[] Arr=new test[9];
Class clazz = Test[].class;
System.out.println (clazz);
Class Clasz = Test.class;
System.out.println (Clasz);
}
The result:
You can see that the array class is not the same as the normal class.
But the array class has its own parent class, which prints the parent class of the array class.
System.out.println (Clazz.getsuperclass ());
So the array class can be counted as a special class.