I have a Float variable which is initialised from a function returning the Float value, and there can be chance to return null in some cases. So I need to check the value in the variable is null or empty. If the value is empty I need to initialise variable wb1 with value 1. I am using Java Spring. This is the code currently I amusing,
Float wb1 = !StringUtils.isEmpty(getArea())?getArea() : 1.0f;
Float is an object and
float is the primitive type.
null check is used for objects. For primitives you should use the default values check. For float the default value is 0.0f.