Chapter 4: Fundamental Data Types
Primitive Types
- byte, short, int, long (e.g. 10)
- float, double (e.g. 10.50)
- boolean (e.g. true, false)
- char (character, e.g. 'a')
Useful Numbers Tips
- casting, e.g. int dollar = (int) 10.50;
- Math library methods, e.g. Math.round(double), Math.floor(double), etc.
Constants
- Method constant, e.g. final double DIME_VALUE = 0.10;
- Class constant, e.g. public static final double DIME_VALUE = 0.10;
- Tip: use constants instead of magic numbers
Assignment Operator
- int year = 2007;
- year = year + 1;
- year++;
- year--;
Lecture Code