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

    Updated: Oct 26, 2024
    Views: 1.1K
    sorry the last line of code is





    System.out.println(a.length);

    what exactly length is...😎
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Kaustubh Katdare

    AdministratorJun 19, 2012

    Please post the full code in the post, title is just a title.
    Are you sure? This action cannot be undone.
    Cancel
  • Dancer_Engineer

    MemberJun 19, 2012

    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'.
    Are you sure? This action cannot be undone.
    Cancel
  • Vikash Verma

    MemberJun 19, 2012

    I mean to find array length , we use arrayname.length .
    What is this length variable, where it is generated, is arrayname a class,. . .
    Are you sure? This action cannot be undone.
    Cancel
  • Anoop Kumar

    MemberJun 19, 2012

    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 <variable> length. as array length is constant which stores length of array.
    Are you sure? This action cannot be undone.
    Cancel
  • Dancer_Engineer

    MemberJun 19, 2012

    #-Link-Snipped-#, you may take a look at these links:
    <a href="https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html" target="_blank" rel="nofollow noopener noreferrer">Arrays (The Java™ Tutorials > Learning the Java Language > Language Basics)</a>
    <a href="https://www.roseindia.net/java/master-java/Reference-Data-Types.shtml" target="_blank" rel="nofollow noopener noreferrer">Reference Data Types</a>
    Are you sure? This action cannot be undone.
    Cancel
  • suraz

    MemberJun 19, 2012

    #-Link-Snipped-#
    check this out
    Are you sure? This action cannot be undone.
    Cancel
  • Vikash Verma

    MemberJun 19, 2012

    #-Link-Snipped-# you are right...😎
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register