How is boolean xx = (43.3L == 3.333f) syntactically correct

94 Views Asked by At

I'm have a problem with understanding this question about syntax it says the answer is

boolean xx = (43.3L == 3.333f);

but i don't understand how it is

Which of the following Java statements are NOT syntactically correct?

boolean x = (0.600 == 3.3d);
boolean bw = (false == true);
double dd = 2.5d;
boolean xx = (43.3L == 3.333f);
String\[\] se =new String\[6\];
1

There are 1 best solutions below

1
Marc Le Bihan On BEST ANSWER

No boolean xx = (43.3L == 3.333f) isn't correct and the IDE refuses it.

With 43.3L you ask to consider a decimal number (=> a float or double in Java) as a long (the L).

If you remove the L the expression will evaluate.

The three others evaluate.

enter image description here