-2

I have gone through Java tutorials but a confusion about arrays is still there in my mind.

How array works internally? From where the data member length comes?(when we have to get the length of dynamic array, we usually use array.length)

  • 7
    Possible duplicate of [How array works internally in Java?](http://stackoverflow.com/questions/26069704/how-array-works-internally-in-java) – Gooz Apr 07 '17 at 10:01

1 Answers1

2

There is no "member function" length(). There's a (final) property length that tells the size of the array. Arrays are objects, but they're mainly native implemented. Basically they're pointers with bounds checking.

You don't need to worry about the internal implementation of arrays, they work just fine.

Kayaman
  • 72,141
  • 5
  • 83
  • 121
  • Thanks for the answer Kayaman. What you are telling as 'native implementation'; is it same as the term 'proxy classes' which I have heard by any of my colleagues. – Shashank Shekhar Singh Apr 11 '17 at 09:07
  • No, it means that there's a platform dependent native implementation in the JVM that handles arrays. You don't need to care how they are actually implemented, but in any normal JVM it would be a "smart pointer". – Kayaman Apr 11 '17 at 09:27