javabooleanboolean-expressionboolean-operations

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


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\];

Solution

  • 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