Java will raise an error if it finds a mismatch of data types between the variable and the value assigned to it. This is because Java is strongly typed. To avoid this problem and still assign similar data types (such as double value to an integer variable), type conversion/casting is needed.