In my opinion the code above shoulnd't compile but it does.
It shouldn't compile because in line 2 there is an implicit conversation from long to int which shouldn't be allowed by compiler ??
It's explained in the JLS under widening conversions on page https://docs.oracle.com/javase/specs/jls/se7/html/jls-5.html but be warned the JLS can be difficult to read.
John Losty wrote:and if long is used in arithmetic operation it is not converted to int?
The long primitive type is wider than the int primitive type. And Java does not support the implicit narrowing of a long to an int -- if you want the result of the arithmetic operation to be converted to an int, you will need to explicitly cast it.
I hope the rest of that tutorial is better than that page, which is very unclear, and I believe contains errors. I think the errors are all near the beginning.
John Losty wrote:. . . https://www.w3resource.com/java-tutorial/java-arithmetic-operators.php
John Losty wrote:It shouldn't compile because in line 2 there is an implicit conversation from long to int
No, it doesn't.
John Losty wrote:I was looking for this part and I don't think it is uncorrect?
Read the third statement there carefully to understand why your previous affirmation is wrong.