An int array problem
Hi,
I am having problem with the length of an int array. When I use System.out.print to print the size of the array, I always get size 0. Any ideas why?
Thanks!
P.S. recommended.size() is the size of a LinkedList
int [] numbers;
if (recommended.size() < 3) numbers =newint [recommended.size() - 1];
else numbers =newint [2];
System.out.println(numbers.length);
[647 byte] By [
giggipa] at [2007-11-27 2:12:18]

Add a "System.out.println(recommended.size())" first. It must not be what you think it is.(For example, if it is 1, then the THEN branch will execute, andyour array's length will be 1-1==0)
> The size at the minute is 1.
> It will always be above 0.
> Thanks!
I don't understand this message. Are you saying you've solved your problem? Or not?
Is there a question in there somewhere?
(I've just told you, if recommended.size()==1, then you will get an array of length 0)