| Author |
args.length
|
ramchander yshetti
Ranch Hand
Joined: Apr 22, 2006
Posts: 97
|
|
hai public static void main(String args[]) {.... ..... for(int i=0;i<=args.length;i++) can you tell me args.length(it returns the length of the array) .length is what it is function or keyword where it is in api. ..... ...
|
 |
Ganesh Kumar
Ranch Hand
Joined: Jul 02, 2007
Posts: 113
|
|
Hi Ramachander Length is function which returns an value of the length of the data you have given.
|
 |
Gavin Tranter
Ranch Hand
Joined: Jan 01, 2007
Posts: 333
|
|
I was always thoughts arrayObject.length was actual a property, a public final variable of the "array" class and not a method, as a method requires brackets: (). [ July 26, 2007: Message edited by: Gavin Tranter ]
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24059
|
|
Syntactically, it's an instance member -- i.e., in the code it looks like a variable. But in reality, it is compiled to a special bytecode which returns the length of an array object; it's not a "real" instance member of the array object. yathamshetti ramchander -- "length" isn't anywhere in the API because it's not a member of any class that's documented in the API. Instead, it's a feature of the Java language. You learn about it from the language specification, or (more likely) from any introductory Java book. Don't worry that there are many things like this to learn. There is only one similar feature in all of Java -- one other thing that looks like a member variable, but isn't. That's the static "class" member. You can say, for example, "String.class" to get a java.lang.Class object that represents the class java.lang.String.
|
[Jess in Action][AskingGoodQuestions]
|
 |
 |
|
|
subject: args.length
|
|
|