Hey,
There is one main difference. This statement is an expression in Scala, but not in Java. There, we cannot assign it to a variable because it doesn’t return a value.
Here is an example below:
scala> val x=3
x: Int = 3
scala> val kind= if(x%2==0) "even" else "odd"
kind: String = odd
Java:
int x=3;
String kind;
if(x%2==0)
kind=”even”;
else
kind=”odd”;
Hope this helps!
Check out Java online course to learn more about it.
Thanks!