Is an array an object in Java?

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.


Yes.

The Java Language Specification section 4.3.1 starts off with:

An object is a class instance or an array.


Well, let's ask Java!

public class HelloWorld
{
  public static void main(String[] args)
  {
    System.out.println(args instanceof Object);
    int[] someIntegers = new int[] {42};
    System.out.println(someIntegers instanceof Object);
  }
}

Output:

true
true

Tags:

Java