what does length represents in the following code snippet: int a[]={10,20,30}; System.out.println(a

sorry the last line of code is





System.out.println(a.length);

what exactly length is...😎

Replies

  • Kaustubh Katdare
    Kaustubh Katdare
    Please post the full code in the post, title is just a title.
  • Dancer_Engineer
    Dancer_Engineer
    If this is your code:
    int a[] = {10,20,30};
    System.out.println(a.length);
    Here 'a.length' gives the length of the array 'a'.
  • Vikash Verma
    Vikash Verma
    I mean to find array length , we use arrayname.length .
    What is this length variable, where it is generated, is arrayname a class,. . .
  • Anoop Kumar
    Anoop Kumar
    I tried to find out source code for array but didn't got it. There is array class in java.lang.reflect package but that is different and similar to array functionality.

    Well answer is Array is not a class. Its a reference type. There are three reference type in java class, interface and array
    it is built-in JVM part and array.length is defined as
    public final length. as array length is constant which stores length of array.
  • Dancer_Engineer
    Dancer_Engineer
  • suraz
    suraz
    #-Link-Snipped-#
    check this out
  • Vikash Verma
    Vikash Verma
    #-Link-Snipped-# you are right...😎

You are reading an archived discussion.

Related Posts

Galaxy Note II, the next installment in the 7 million strong Galaxy Note series is expected to be available by October 2012; around the same time as iPhone 5. Samsung...
Flipkart has forayed into the online toy store! The online megastore now lists toys into various categories for different age ranges. Interesting! See: https://www.flipkart.com/toys
Hi guys, i need help regarding the application of heat generation along a direction in ansys
Pratt and Whitney's new Pure Power Geared Turbofan engines are said to be more fuel efficient and emit less carbon-dioxide than its predecessors and competitors. The engine achieves it efficiency...
Today morning when I flipped open our local newspaper, I saw an ad from the Ministry of Social Justice & Empowerment, India that said -> and I suddenly remembered some...