2

While studying about arrays in java I came about this article :

10.7. Array Members The members of an array type are all of the following: The public final field length, which contains the number of components of the array. length may be positive or zero. The public method clone, which overrides the method of the same name in class Object and throws no checked exceptions. The return type of the clone method of an array type T[] is T[]. A clone of a multidimensional array is shallow, which is to say that it creates only a single new array. Subarrays are shared. All the members inherited from class Object; the only method of Object that is not inherited is its clone method.

Can some one please explain to me what this means?

  • 4
    What exactly do you have a question about? What the clone method does, what the `length` field means, or something else entirely? – user Jun 18 '20 at 21:35

2 Answers2

3

10.7. Array Members The members of an array type are all of the following:

This is what you can call on an array type.

The public final field length, which contains the number of components of the array. length may be positive or zero.

You can call array.length, which does what you would expect.

The public method clone, which overrides the method of the same name in class Object and throws no checked exceptions. The return type of the clone method of an array type T[] is T[]. A clone of a multidimensional array is shallow, which is to say that it creates only a single new array. Subarrays are shared. All the members inherited from class Object; the only method of Object that is not inherited is its clone method.

You can call array.clone(), which will return a shallow copy of the array. You can learn more about shallow vs. deep copies here: What is the difference between a deep copy and a shallow copy?

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
Chris
  • 145
  • 8
2

I wouldn't call this passage theory. This explains the member fields and methods that you can use on an array variable. It is very concrete and practical. Chris explains the details very well in the other answer. I suggest you learn more about classes, member fields, and methods. Learning the fundamental terminology of classes and objects will help you understand what this is saying.

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268