• 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

arg.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
can you clear me where the arg.length.
the length is there

public static void main(String arg[])
{

int n = arg.length; // in api - i dont find length field.
length() fuction is there but length.
}
please clear where length is there
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by ramchander yathamshetti:
length() fuction is there but length.



String contains length()
Array contains length
see the methods available in array

Hope This Helps
 
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You won't find the length field of an array in the Java doc APIs (as far as I know). It is just simply something you learn about when learning Java. Other than the length field, the only methods you can call on an array itself (not an element of the array, but the array itself) are the standard methods from the Object class.

As seetharaman venkatasamy pointed out, the length() method is a method of the String class, as well as the CharSequence class, StringBuffer class, and a number of other classes. (You can look them all up in the Java Doc Index.)

For some more discussion on Arrays, including their length, you can look at this recent thread.
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mark Vedder:
You won't find the length field of an array in the Java doc APIs

That is because you won't find "array" in the Java API documentation at all. You need to look in the Java Language Specification; look for �10.7 for "length."
 
ramchander yshetti
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
i am not cleared with the answer
int a[]={.....}
int n= a.length;

where can i find length field in javadoc
please give me clear answer.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please read the two posts above yours carefully. The answer has already been given.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic