Java: Scalar class