Unit 3 Notes
Casting and Ranges of Variables
- That number is 23^2
-
The negative one is one larger because 0 is included.
-
Integers can be represented from -2^31 through (2^31-1) which would be 2^32 numbers total. We do minus one on the last number because 0 is included.
-
Integer.MAX_VALUE and Integer.MIN_VALUE are in the Integer class.
- If you were to do the max number plus one, java will return the min value. Same with the min, if you did min number minus one, java will return the max number. This is because it is looping through a circle. This is an overflow error.
Autoboxing Autoboxing (done by the compiler): turning the primitive type into their associated wrapper class Unboxing (done by the compiler): turning the wrapper class into their associated primitive type
- Primitive data types only store a single value (int, double, boolean)
- Reference types only stores references (strings, arraylists)
- Wrapper classes are used to convert from primitive to reference types
Conditionals with Boolean Expressions
- Booleans store a true/false value (can only be one of these)
- Booleans can be generated using comparison expressions (equal/==, greater than/>, less than/<, etc.)
- If statements take in a boolean or boolean expression and run if the expression evaluates to “true”
- Else & Else if statements can be used in conjunction with if statements to run code if the if statement evaluates to false
- Using combinations of boolean operators, you can make compound boolean expressions Operators that can be used include and (&&), or (||), not (!), as well as parenthesis for grouping purposes