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]
# 1
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)
KathyMcDonnella at 2007-7-12 2:06:25 > top of Java-index,Java Essentials,Java Programming...
# 2
The size at the minute is 1.It will always be above 0.Thanks!
giggipa at 2007-7-12 2:06:25 > top of Java-index,Java Essentials,Java Programming...
# 3

> 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)

KathyMcDonnella at 2007-7-12 2:06:25 > top of Java-index,Java Essentials,Java Programming...
# 4
Ah, I see what you mean. Sorry, I was getting confused.Thanks alot for your help! Much appreciated!
giggipa at 2007-7-12 2:06:25 > top of Java-index,Java Essentials,Java Programming...
# 5
You're welcome. Good luck.
KathyMcDonnella at 2007-7-12 2:06:25 > top of Java-index,Java Essentials,Java Programming...