File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Array documentation Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Array documentation" Watch "Array documentation" New topic
Author

Array documentation

Patrick Cicero
Greenhorn

Joined: Nov 06, 2002
Posts: 4
In alot of java code examples they show code like
int[] myArray = new int[10]
for(int i = 0; i < myArray.length; i++)
{
myArray[i] = i+10;
}
I think I have seen this use of the Array.length field to get the length of an Array even on SUN web pages. But the API documentation does NOT show the Array Class as having a Class field of length, but it must have this field.
Am I totaly messed up or is the API incomplete?
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Welcome to JavaRanch, Patrick!
I believe that the cause of your confusion is understanding what Array is versus what an array of some data type is.
The Array class is a utility class that provides static methods to create and access arrays. Array is not an array of some data type (such as an array of int or String - int[] or String[]).
The interface of an array of some data type is considerably different than the interface of Array. The interface of an array of some data type does provide access to the final length field.
Is this starting to make more or less sense?


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Cindy Li
Greenhorn

Joined: Oct 31, 2002
Posts: 4
Array Type is literally represented by [].
It is described in the Jave Language Specification, http://java.sun.com/docs/books/jls/second_edition/html/arrays.doc.html#25518 -- 10.7 Array members.
(not in Java 2 Platform API Specs)
Array Type defines a member field 'length' as public final.
Hope that helps.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Array documentation
 
Similar Threads
Sorting Issue Help Needed Badly
Arrays doubt
Enumerated type
Constructing multidimensional arrays
Sorting an array