Re: intitialising an array

Discussion in 'Java' started by Ike, Aug 26, 2003.

  1. Ike

    Ike Guest

    Yes, but I dont want to in this instance....

    "Tor Iver Wilhelmsen" <> wrote in message
    news:...
    > "Ike" <> writes:
    >
    > > Now, if, instead I dont know how many of the second tuples (the
    > > {.16,.16,.16,.16,.16,.3}) I am going to have to add, as this can
    > > change each time the class containing t is instantiated....how would
    > > I thus initialise this? That is, I know the first tuple ({10,100,
    > > 0,10}), will always be the same size and values, but the second one
    > > is variable in terms of size and values.

    >
    > You could leave it as null. It's perfectly possible to set array
    > values afterwards when you know the values.
     
    Ike, Aug 26, 2003
    #1
    1. Advertising

  2. Ike:

    >Yes, but I dont want to in this instance....


    With a double[] variable - and any t of your t is of type double[]
    - you can assign null or create a 1-D array of a certain length. If
    that doesn't work for you, use a List - possibly a List of List
    objects - and put Double (in java.lang) values into it. Then, after
    your lengthy initialization process, you could create a 2-D double
    array from the List.

    Regards,
    Marco
    --
    Please reply in the newsgroup, not by email!
    Java programming tips: http://jiu.sourceforge.net/javatips.html
    Other Java pages: http://www.geocities.com/marcoschmidt.geo/java.html
     
    Marco Schmidt, Aug 26, 2003
    #2
    1. Advertising

  3. Ike

    Ike Guest

    Ah, lads, here it is....(for the benefit of anyone doing a future search and
    stumbling upon this...)

    //the variables are
    //int theSize;
    //double theValue;

    double tt[]=new double[theSize];
    for(a=0;a<theSize;a++){
    if(a<theSize-1)
    tt[a]=theValue;
    else
    tt[a]=.3;
    }
    double t[][]=
    {{10,100, 0,10},
    tt};


    "Marco Schmidt" <> wrote in message
    news:...
    > Ike:
    >
    > >Yes, but I dont want to in this instance....

    >
    > With a double[] variable - and any t of your t is of type double[]
    > - you can assign null or create a 1-D array of a certain length. If
    > that doesn't work for you, use a List - possibly a List of List
    > objects - and put Double (in java.lang) values into it. Then, after
    > your lengthy initialization process, you could create a 2-D double
    > array from the List.
    >
    > Regards,
    > Marco
    > --
    > Please reply in the newsgroup, not by email!
    > Java programming tips: http://jiu.sourceforge.net/javatips.html
    > Other Java pages: http://www.geocities.com/marcoschmidt.geo/java.html
     
    Ike, Aug 26, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Daniel
    Replies:
    1
    Views:
    1,054
    Kevin Collins
    Aug 14, 2003
  2. S300
    Replies:
    4
    Views:
    22,000
    Roedy Green
    Aug 19, 2003
  3. Mara Guida

    const and array of array (of array ...)

    Mara Guida, Sep 2, 2009, in forum: C Programming
    Replies:
    3
    Views:
    495
    David RF
    Sep 3, 2009
  4. Tom
    Replies:
    3
    Views:
    213
    salsablr
    Dec 20, 2004
  5. Tuan  Bui
    Replies:
    14
    Views:
    476
    it_says_BALLS_on_your forehead
    Jul 29, 2005
Loading...

Share This Page