Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Simple array question

Reply
Thread Tools

Simple array question

 
 
Gianni
Guest
Posts: n/a
 
      03-01-2005
// 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
 
Reply With Quote
 
 
 
 
Antti S. Brax
Guest
Posts: n/a
 
      03-01-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) 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.
 
Reply With Quote
 
 
 
 
Tor Iver Wilhelmsen
Guest
Posts: n/a
 
      03-01-2005
(E-Mail Removed) (Gianni) writes:

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


You don't use the [] when using the variable, just "cars".
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
const and array of array (of array ...) Mara Guida C Programming 3 09-03-2009 07:54 AM
simple, simple array question Peter Bailey Ruby 7 04-08-2008 01:54 PM
length of an array in a struct in an array of structs in a struct in an array of structs Tuan Bui Perl Misc 14 07-29-2005 02:39 PM
Length of Array of Array of Array Tom Perl Misc 3 12-20-2004 05:23 PM
Re: Simple Simple question!!! ashelley@inlandkwpp.com ASP .Net 0 06-25-2004 04:18 PM



Advertisments