Type and Value
- 1, 1.0, '1',"1" are different data types (stored and represented in a computer)
- two categories:
- primitive types
boolean (true false)
byte(8-bit) short(16-bit) int(32-bit) long(64-bit) signed two's-complement integers
char (16-bit unsigned integers representing Unicode characters)
float(32-bit) double(64-bit) IEEE 754 floating-point numbers
- reference types
interface types and array types
class types e.g. String, Graphics, Applet, Color, and Integer
- in Java, all variables/identifiers must be declared before they can be used, why?
a = b + c (int = int + int or float = float + float or String = String + String)
b + c is an example of expression, like variables, has both value and type which depends critically on the types and value of the constants, variables ,and function calls making up the expression
- Type Conversion and Casting Type Conversion