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) {
				System.out.println("CORRECT!!");
			}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

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.