× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



    Hi Robert,

    I think this answers what you are asking.

>   1. How do I prototype the someMethod so that it accepts an array.

    You pretty much have it already.  My preference is to put the brackets
with the type rather than the variable.  If no access is given, the default
is package access.  A return type must be given, use void if nothing is
returned.

<access>  <ReturnValueType> someMethod( MyClassA[] myClass )
{
}

>   2. How do I define a field to be an array MyClass[].

MyClass[] myClass;


>   3. How do I instantiate the array field from 2.

    Assumes the declaration from above.

myClass = new MyClass[ NumberOfElements ];

    Note that all elements are initially null for Object arrays.  You have
to load it with objects.

    You can do the declaration and create the array in one step as:

MyClass[] myClass = new MyClass[ NumberOfElements ];

    See The Java Tutorial and the Java Language Specification for more
information about arrays, variable declarations and loading.


                                                         Joe Sam

Joe Sam Shirah -        http://www.conceptgo.com
conceptGO         -        Consulting/Development/Outsourcing
Java Filter Forum:       http://www.ibm.com/developerworks/java/
Just the JDBC FAQs: http://www.jguru.com/faq/JDBC
Going International?    http://www.jguru.com/faq/I18N
Que Java400?             http://www.jguru.com/faq/Java400


----- Original Message -----
From: "Robert Upshall" <rupshall@xxxxxxxxxxx>
To: <java400-l@xxxxxxxxxxxx>
Sent: Wednesday, July 21, 2004 3:07 PM
Subject: Java Prototyping Questions?


> I am trying to prototype a java methods and I have some questions:
>
> Example:
>
> I have 2 classes, MyClassA and ThatClassB.  ThatClassB has a method
> someMethod(MyClassA myClass[]).  I have MyClassA and ThatClassB
> prototyped.
>
>   1. How do I prototype the someMethod so that it accepts an array.
>
>   2. How do I define a field to be an array MyClass[].
>
>   3. How do I instantiate the array field from 2.
>
>
> Robert
>







As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.