Is an Array an Object in Java?
In Java, arrays are declared similarly to the example provided:
String[] array = new String[10]; int size = array.length;
However, this leads to the question of whether an array itself is an object. In C , arrays are simply pointers and lack methods.
The Answer
Yes. According to the Java Language Specification (section 4.3.1), an object is defined as "a class instance or an array." This implies that arrays possess object-like characteristics in Java.
The above is the detailed content of Is an Array an Object in Java?. For more information, please follow other related articles on the PHP Chinese website!