areyouready344
asked on
which class is the length data member in java part of?
when i declare and define a java's array variable, for example,
int arrayExample = new arrayExample[100];
Next, I use the following statement to get the array element length,
arrayExample.length
Which class is the length data member part of?
int arrayExample = new arrayExample[100];
Next, I use the following statement to get the array element length,
arrayExample.length
Which class is the length data member part of?
arrayExample.legth is of int type
java.util
Interface: Collections
Classes:Arrays
Class Arrays
java.lang.Object
java.util.Arrays
Interface: Collections
Classes:Arrays
Class Arrays
java.lang.Object
java.util.Arrays
sorry I mis understood the question
http://java.sun.com/j2se/1.5.0/docs/api/
In packages Search and click : java.util
you'll see The interface: Collection
And The Class:Arrays:
on the right and side you'll see the methods implemented by Array
hope that answers your questions!
In packages Search and click : java.util
you'll see The interface: Collection
And The Class:Arrays:
on the right and side you'll see the methods implemented by Array
hope that answers your questions!
@himanshut: java.util.Arrays doesn't have the data member length
length() method belongs to the String class
I donot think that length is acquired from a class. If we see the methods and variables that the array has, it acquires the length from int[], which seems to point to the compiler, which inserts the length variable fro the array.
Have a look at the image.
untitled.JPG
Have a look at the image.
untitled.JPG
Java arrays are classes and length is a (public final) member of that class
"The public final field length, which contains the number of components of the array (length may be positive or zero)"
http://java.sun.com/docs/books/jls/second_edition/html/arrays.doc.html
"The public final field length, which contains the number of components of the array (length may be positive or zero)"
http://java.sun.com/docs/books/jls/second_edition/html/arrays.doc.html
"Arrays are first-class objects
Regardless of what type of array youre working with, the array identifier is actually a handle to a true object thats created on the heap. The heap object can be created either implicitly, as part of the array initialization syntax, or explicitly with a new expression. Part of the heap object (in fact, the only field or method you can access) is the read-only length member that tells you how many elements can be stored in that array object. The [] syntax is the only other access that you have to the array object. "
Ref - http://www.codeguru.com/java/tij/tij0087.shtml
Regardless of what type of array youre working with, the array identifier is actually a handle to a true object thats created on the heap. The heap object can be created either implicitly, as part of the array initialization syntax, or explicitly with a new expression. Part of the heap object (in fact, the only field or method you can access) is the read-only length member that tells you how many elements can be stored in that array object. The [] syntax is the only other access that you have to the array object. "
Ref - http://www.codeguru.com/java/tij/tij0087.shtml
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.