Is an array an object in Java?

前端 未结 12 1755
我寻月下人不归
我寻月下人不归 2020-11-22 14:26

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

12条回答
  •  孤街浪徒
    2020-11-22 15:01

    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
    

提交回复
热议问题