Chapter 2. Working with Java data types
This chapter covers:
- [2.2] Differentiate between object reference variables and primitive variables. The primitive data types in Java, including scenarios when a particular primitive data type should or can’t be used. Similarities and differences between the primitive data types. Similarities and differences between primitive and object reference variables.
- [2.1] Declare and initialize variables (including casting of primitive data types). Declaration and initialization of primitives and object reference variables. Literal values for primitive and object reference variables.
- [2.5] Develop code that uses wrapper classes such as Boolean, Double, and Integer. How and when values are boxed and unboxed when used with wrapper classes.
- [3.1] Use Java operators; including parentheses to override operator precedence. Use of assignment, arithmetic, relational, and logical operators with primitives and object reference variables. Valid operands for an operator. Output of an arithmetic expression. Determine the equality of two primitives. How to override the default operator precedence by using parentheses.
Imagine that you’ve just purchased a new home. You’ll likely need to buy different-sized containers to store different types of food items, because one size can’t fit all. Also, you might move around food items in your home—perhaps because of a change in the requirements over time (you wish to eat it or you wish to store it).