The Java double d = 3; converts to val d = 3, which is incorrect since the inferred type in Scala will be an Int, but it should be a Double. There needs to be an explicit type annotation, or it needs to be suffixed with d (val d = 3d), at least when there is no decimal point to make the inferred type correct.
The Java
double d = 3;
converts toval d = 3
, which is incorrect since the inferred type in Scala will be an Int, but it should be a Double. There needs to be an explicit type annotation, or it needs to be suffixed with d (val d = 3d
), at least when there is no decimal point to make the inferred type correct.