The Artima Developer Community
Sponsored Link

Java Answers Forum
quick question on main(String[] argv)

1 reply on 1 page. Most recent reply: Oct 30, 2003 12:14 AM by Alex S

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Guido

Posts: 38
Nickname: kiethb
Registered: May, 2002

quick question on main(String[] argv) Posted: Oct 29, 2003 9:38 AM
Reply to this message Reply
Advertisement
If i want to get the number of parms passed into the program I need to use argv.length

however, what class does variable 'length' reside? it is not a method, so must be a class variable. what class is this in and why are we not retrieving this class variable via a method.

my misunderstanding is based on the fact that I tried to use the API docs to locate this field, however could not find it. I also tried using argv.length(); which obviously didnt work.

so in general I am comfortable searching the API for classes and methods and exception, but I want to understand what I am missing when it goes to the field level.

thanks


Alex S

Posts: 27
Nickname: andu
Registered: Mar, 2003

Re: quick question on main(String[] argv) Posted: Oct 30, 2003 12:14 AM
Reply to this message Reply
http://www-106.ibm.com/developerworks/java/library/j-arrays/

"Arrays are the only collection support defined within the Java programming language. They are objects that store a set of elements in an order accessible by index, or position. They are a subclass of Object and implement both the Serializable and Cloneable interfaces. However, there is no .java source file for you to see how the internals work. Basically, you create an array with a specific size and type of element, then fill it up."

http://java.sun.com/docs/books/jls/second_edition/html/arrays.doc.html#27805

"10.7 Array Members
The members of an array type are all of the following:

The public final field length, which contains the number of components of the array (length may be positive or zero)


The public method clone, which overrides the method of the same name in class Object and throws no checked exceptions


All the members inherited from class Object; the only method of Object that is not inherited is its clone method"

Flat View: This topic has 1 reply on 1 page
Topic: Trouble with import com.bruceeckel.simpletest.* Previous Topic   Next Topic Topic: help!!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use