Lesson 4: Types, Variables, and Assignments
In this lesson, we learn about the different primitive types supported by Java (and the non-primitive type String).
1. Variable Declaration and Assignment
We learn how to declare variables and how to assign them.
2. Basic Type Compatibility
We learn that some types are losslessly compatible. We can, for instance, assign an integer (
int) value into a
long variable and it will be stored right nively.
We can also store an
int into a
double without losing anything. However, there are some
long values which will be rounded if we try to store them in a