aspose file tools*
The moose likes Beginning Java and the fly likes where to check the length instance  variable  for an Array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "where to check the length instance  variable  for an Array" Watch "where to check the length instance  variable  for an Array" New topic
Author

where to check the length instance variable for an Array

sai prasanna
Ranch Hand

Joined: May 02, 2005
Posts: 167
hi all
we have length instance variable for an array how to view this instance variable as we view methods in java API

thanks in advance
sai prasanna
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
An array is an object and it is an instance of a class which ought to document the length attribute. I don't think it's in the API docs at all, though. Arrays are one of those dirty little corners in the language where they can say "Everything works like this ... except array"

You can try to explore the class through reflection. This much works:

Look into the Class class for ways to explore the methods and attributes.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14273
    
  21

Your question is not clear.

The "length" property that arrays have in Java is not a real instance variable. It's just a special Java keyword. It's part of the Java language, not of the standard API, so it isn't documented in the API documentation.

What is it exactly that you want to know?


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Dan Patterson
Greenhorn

Joined: Jan 27, 2005
Posts: 24
Actually, length is a read-only data field that specifies the number of elements in the array.
Vlado Zajac
Ranch Hand

Joined: Aug 03, 2004
Posts: 245
It is not defined in API doc, it is defined in the Java Language Specification
 
Don't get me started about those stupid light bulbs.
 
subject: where to check the length instance variable for an Array