One way is to just state the array type and name and then in the constructor
actually instantiate the array EXAMPLE:
public class Class {
  private String[] array; //This is a String array who's name is "array"

  public Class(int size){arrary = new String[size];}
}

hope that helps.
Another way (although it isn't considered the best) is to use a maximum number.
(String[] array = new String[100].  A third way is to use a Vector which
requires you to import java.util*   .  Vectors grow is size with the addition of

elements.  So for example if your vector is set at a size of 10, and you insert
the 11th object, then the vector will automatically grow to fit that 11th
element.  By default it will double in size, but you can also control how fast
it grows.  Furthermore the size() will return the number of occupied elements
not the alloted size.(A vector that has room for 10, but only has 8 filled will
return 8).

If you want e-mail back.

Manu Tayal wrote:

> Hi,
>    I have just now started using java and it is my first encounter with
> OOP and classes. I want to know whether the class defination having an
> int type member variable(say x) and an array with the index as x is correct
> or not. If not what could be the way to handle arrays whose maxlength is not
> fixed but depends on something else.
>
>         Thanks in advance for the help.
>
> Regards,
> Manu.
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> #  MANU TAYAL                   |      WIPRO INFOTECH                     #
> #                               |      30,Mission Road, 1st Main,         #
> #  Software Engineer            |      S.R.Nagar,                         #
> #                               |      Bangalore-560027,India.            #
> #  Technology Solutions         |                                         #
> #                               |      TEL: 080-2241730/2275590           #
> #  WIPRO INFOTECH.              |      EXT: 3322,3321,3323                #
> #                               |   E-Mail: [EMAIL PROTECTED]       #
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html




Manu Tayal wrote:

> Hi,
>    I have just now started using java and it is my first encounter with
> OOP and classes. I want to know whether the class defination having an
> int type member variable(say x) and an array with the index as x is correct
> or not. If not what could be the way to handle arrays whose maxlength is not
> fixed but depends on something else.
>
>         Thanks in advance for the help.
>
> Regards,
> Manu.
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> #  MANU TAYAL                   |      WIPRO INFOTECH                     #
> #                               |      30,Mission Road, 1st Main,         #
> #  Software Engineer            |      S.R.Nagar,                         #
> #                               |      Bangalore-560027,India.            #
> #  Technology Solutions         |                                         #
> #                               |      TEL: 080-2241730/2275590           #
> #  WIPRO INFOTECH.              |      EXT: 3322,3321,3323                #
> #                               |   E-Mail: [EMAIL PROTECTED]       #
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to