• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

args.length

 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.



.....
...
 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ramachander
Length is function which returns an value of the length of the data you have given.
 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic