Car is a class I already made.
What I want the code to do is to return true in the green method if there are null valors in the testPark array.
If the testPark array is full i.e. there are no nulls then the green method should return false.
With the code as it is, the testPark array should have only null valors, and the green method should return true, but i get false instead. What am I doing wrong?
Thanks for every piece of imput you'll give me.

EDIT: some lines like the import one and the freeSpaces one are there for future methods.

Re: Boolean Method Problem

Originally Posted by diamonddragon

OF course, primitive can not be null, so if (spaces[i] == null) should be replaced with if (spaces[i] == 0).

So without seeing all of his code, without seeing his Car class (which he tells us in his initial post that he already has), you declare that he should not use this class, that he must use an array of int? Based on what information do you make this declaration?

Re: Boolean Method Problem

Originally Posted by Fubarable

So without seeing all of his code, without seeing his Car class (which he tells us in his initial post that he already has), you declare that he should not use this class, that he must use an array of int? Based on what information do you make this declaration?

Re: Boolean Method Problem

Firstly your line number 10 in Parking class should give you an error since you are using Car and car either it will have an uppercase or lowercase "c" depending
upon your "car" or "Car" class.

I have to admit that I did not post the original code since all the variables were wrote in Italian. I did modify the variables, methods and classes names in English to make the post easyer to read. While doing that, I made a typing error. In the original code "car" is actually "Car".

Regarding this

So without seeing all of his code, without seeing his Car class (which he tells us in his initial post that he already has), you declare that he should not use this class, that he must use an array of int? Based on what information do you make this declaration?

As You say, without seeing his Car class.

I apologize for not posting all the infos needed.
Here is my Car class:

Re: Boolean Method Problem

Originally Posted by Bonfy

I still don't get where the error could be anyway :(

Jos must again be posting his answers with invisible ink, a problem that we've tried to have corrected time and again, but he never listens. I'll warn him again not to do this. Until then, you may wish to re-read his answer above, since it shows you probably what is wrong -- an errant semicolon that is short-circuiting the if block.

Re: Boolean Method Problem

Originally Posted by Fubarable

Jos must again be posting his answers with invisible ink, a problem that we've tried to have corrected time and again, but he never listens. I'll warn him again not to do this. Until then, you may wish to re-read his answer above, since it shows you probably what is wrong -- an errant semicolon that is short-circuiting the if block.

I see what you're saying there, sorry for missing Jos' answer.
After erasing that horrible semi colon I'm still having the same exact issue i.e. getting "false" on the screen.
Thanks for the answers again.

Re: Boolean Method Problem

Originally Posted by Bonfy

I see what you're saying there, sorry for missing Jos' answer.
After erasing that horrible semi colon I'm still having the same exact issue i.e. getting "false" on the screen.
Thanks for the answers again.

Have you followed my recommendation to set your class's totalSpaces field in the constructor? If not, you understand that totalSpaces currently == 0 right? So the for loop won't even be called.