Is an array an object in Java?

前端 未结 12 1764
我寻月下人不归
我寻月下人不归 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

    Arrays of anything are objects. One can call methods such as equals, hashcode etc:

    final int[] i = {};
    i.equals(new int[] {1});  // false
    i.hashcode();
    

    One cannot call methods on a native type.

提交回复
热议问题