so i need some help, have random int that decide which values in my Boolean array are true. All th

System.out.println ("pick a number 1-9");
	int guess;
	for ( int i = 0; i < 9; ++i ){
		 guess = console.nextInt();	

		if (x[i] = true) {
			}else if (x[i] = false) {
				System.out.println("eeeehhh wrong");
	System.out.print("The battleships were placed at locations " + Arrays.toString(x));		

the problem with this i have noticed is it compares the whole array not going through and just hitting the values that are true

8 Years
Discussion Span
Last Post by pirateninja1111

The comparison operator in Java is "==" not "=".
Change that on line numbers 7 and 9 and check whether it works.

"=" is the assignment operator, so you are actually setting the value to your array element there.

Edited by stephen84s: n/a


i changed it to == it'll work but only if i type the numbers in order starting at 0 if not it's will say it's false when it is true


ok i feel like an idiot that is not in any way what i was supposed to do. just figured it out and i don't think what i was trying to do was possible lol

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.