In Java we can declare an array using the following:
String[] array = new String[10];
int size = array.length;
Does this mean that the arra
Yes; the Java Language Specification writes:
In the Java programming language, arrays are objects (§4.3.1), are dynamically created, and may be assigned to variables of type Object (§4.3.2). All methods of class Object may be invoked on an array.
I just want to add that arrays have a representation in the reflection API - java.lang.reflect.Array.
Yes, it is an object in Java.
Also note that when you do array.length
you're not invoking any methods but just accessing the array's length
field. There are plenty of static methods in the Arrays class.
I would say the answer is yes, although I might add that, strictly speaking, an array is an object in C++ too. From §1.8 [intro.object] of the current standard (FDIS):
An object is a region of storage.
Yes.
The Java Language Specification section 4.3.1 starts off with:
An object is a class instance or an array.
Every array in java is an object ex int[] a=new int [2]; So new is used to create an object and as it is an object we can check the class name just using a.getClass().getName();