by Michael Thomas
by Michael Thomas
Objectives (topics)
Topic | Notes | ||||||||||||||||||||||||||||||||||||
Data Types | Java has 2 categories of data types: Objects
or Primitives Primitive - a place in memory that
stores a value. Everything in Java is either an object or a primitive. |
||||||||||||||||||||||||||||||||||||
Primitive - Bit Sizes
|
Formula for Integers Min/Max values. (On the test!)
The info in the table is on the test. Remember byte, char, & boolean min/max value! You can skip the # values for short through double.
|
||||||||||||||||||||||||||||||||||||
Default data types for numbers | Default data types: integers - int floating points - double |
||||||||||||||||||||||||||||||||||||
Data Type initial values. | Instance variables - get initialized with
default values. Static variables - get initialized with default values. Local variables - must be initialized before they are used. Instance & Static Variables default values.
|
||||||||||||||||||||||||||||||||||||
Exceptions | Integers - throw exceptions Floating-point - never throw exceptions Divide by 0: Any arithmetic expression involving a NaN yields NaN. NAN = "not-a-number" |
||||||||||||||||||||||||||||||||||||
Casting | Casting is used to force an explicit conversion of data from
one type to another. 2 types of casting
Remember: When casting up and down the hierarchy, you can implicitly cast up but you must explicitly cast down. You can not implicitly coerce a data type with greater accuracy into a data type with less accuracy. Therefore, if loss of data is possible when you are converting to another data type, then you must insert a cast or the compiler will complain. Legal statements
Illegal statements
|
||||||||||||||||||||||||||||||||||||
Not on the Test |
|