+ 1

I wrote an if statmate with an equal sign and it gave me an error say in it can't be turned into a boolean.

if (answer = 18) { System.out.println("your a teen, get it, 'a' teen"); ./Playground/Program.java:39: error: incompatible types: int cannot be converted to boolean if (answer = 18) { ^ 1 error

9th Jul 2024, 10:25 PM
superorca2
5 Réponses
+ 5
== is comparison = is assignment
10th Jul 2024, 1:08 AM
Lisa
Lisa - avatar
+ 1
10th Jul 2024, 8:49 PM
Wilbur Jaywright
Wilbur Jaywright - avatar
0
now that's just embarrassing
10th Jul 2024, 8:42 PM
CyberX And CorruptedTiger
CyberX And CorruptedTiger - avatar
0
Wilbur Jaywright take a joke
22nd Jul 2024, 12:31 AM
CyberX And CorruptedTiger
CyberX And CorruptedTiger - avatar
0
CyberX And CorruptedTiger Don’t make fun of beginners trying to learn.
22nd Jul 2024, 2:39 AM
Wilbur Jaywright
Wilbur Jaywright - avatar