© Ron Dai 2019
R. DaiLearn Java with Mathhttps://doi.org/10.1007/978-1-4842-5209-3_17

17. Strong Typed Programming

Ron Dai1 
(1)
Seattle, WA, USA
 

As we have learned at the beginning of this book in Part I, the Java programming language has defined the integer, double, Boolean, String, etc., as basic types. In Java, we cannot assign any value to a variable without defining the variable with a type beforehand. Only after a variable has been defined clearly by a type—for example, integer—are we then allowed to assign an integer value to it and start using it as an integer in the calculation. Once a variable’s type is defined, it cannot be assigned a value with a different type, logically speaking. For instance, if a variable is defined as Boolean, it ...

Get Learn Java with Math: Using Fun Projects and Games now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.