I am creating a program in java that will play tictactoe against you. I am currently working on the Human's turn, where you input the number of the square you would like. No matter what square I choose it says it is already choose. I am using a boolean array to tell whether the squares are empty or not, false = empty and true = taken. I can not figure out what the problem is. Any suggestions or advice would be greatly appreciated.
Andy Hammersmith wrote:I know that '==' mean its going to be exactly equal too.
But, I dont know what just one means.
Look at the rest of you program. Are there places where you are using a single equals ? Well, it does the same thing as the single equals in those other places.
Joined: Mar 05, 2008
Andy Hammersmith wrote:A question. We were always told that an '=' wouldnt work, and that you should always use an '=='.
I guess it depends what was meant by "wouldn't work". Most of the time it won't compile at all. Occasionally it will compile, but not do what you want it to. Both can be considered examples of "not working". In either case, you should always use '=='.
Unless, of course, you specifically want to assign a value to a variable, or to an array element. For that, use '='. For everything else, use '=='.