Simple array question

Discussion in 'Java' started by Gianni, Mar 1, 2005.

  1. Gianni

    Gianni Guest

    // i define the array in this way
    String [] cars;
    if (idcriterio30.equals("") && periodoSelezionato <1440)
    {
    // and try to fill it this way
    cars[] = criterio2.split(",");
    }
    else if (periodoSelezionato <= 1440 & criterio30.equals("T"))
    {
    cars[] = idcriterio30.split(",");
    }
    else if (periodoSelezionato > 1440 &&criterio31.equals(""))
    {
    cars[] = criterio2.split(",");
    }
    else if (periodoSelezionato > 1440 && criterio31.equals("T"))
    {
    cars[] = idcriterio31.split(",");
    }

    Why I have an error ??
    thanks
    Gianni, Mar 1, 2005
    #1
    1. Advertising

  2. wrote in comp.lang.java.programmer:
    > // i define the array in this way
    > String [] cars;
    > if (idcriterio30.equals("") && periodoSelezionato <1440)
    > {
    > // and try to fill it this way
    > cars[] = criterio2.split(",");

    <snip>
    > Why I have an error ??


    You have a syntax error. When referring to a variable, be it
    a primitive type, array or another object, you use the variable
    name only:

    cars = criterio2.split(",");

    For further reference, when posting a question asking why you
    get an error it is very helpful if you include the error message
    to the question.

    Also read: http://www.physci.org/codes/sscce.jsp

    --
    Antti S. Brax Rullalautailu pitää lapset poissa ladulta
    http://www.iki.fi/asb/ http://www.cs.helsinki.fi/u/abrax/hlb/
    "Disconnect this cable to shorten, re-connect to lengthen."
    -- Instructions on Logitech's USB mouse extension cord.
    Antti S. Brax, Mar 1, 2005
    #2
    1. Advertising

  3. (Gianni) writes:

    > cars[] = criterio2.split(",");


    You don't use the [] when using the variable, just "cars".
    Tor Iver Wilhelmsen, Mar 1, 2005
    #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. Replies:
    0
    Views:
    551
  2. Kevin Spencer

    Re: Simple Simple question!!!

    Kevin Spencer, Jun 25, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    658
    Kevin Spencer
    Jun 25, 2004
  3. Daniel Frey

    Simple Question - Simple Answer?

    Daniel Frey, Dec 28, 2004, in forum: XML
    Replies:
    4
    Views:
    835
    Daniel Frey
    Jan 12, 2005
  4. Oli

    simple simple question

    Oli, Jan 26, 2004, in forum: ASP General
    Replies:
    10
    Views:
    367
    Roland Hall
    Jan 26, 2004
  5. Peter Bailey

    simple, simple array question

    Peter Bailey, Apr 8, 2008, in forum: Ruby
    Replies:
    7
    Views:
    211
    Peter Bailey
    Apr 8, 2008
Loading...

Share This Page