---
tags: [ap, ap/csa, notes, code]
---
# AP CSA Unit 1 Notes
- **Unit 1**
- naming conventions
- classes
- PascalCase
- methods
- camelCase
- variables
- camelCase
- constants
- UPPER_CASE_SNAKE_CASE
- constants
- in Java, we use the keyword `final` before a variable
definition/assignment to make it a constant
- in C, it's an exact translation to `const`, but is also
equivalent to a `#define` directive
- in JS, that's equivalent to using `const` instead of `let`
- example: [[AP CSA Code Examples#Constants]]
- compound assignment operators
- in Java, we can combine the assignment operator with the basic
operators (+, -, \*, /, %) to make compound assignment operators
- `a += 1` is the same thing as `a = a + 1`
- we can also do `a++`
- `a -= 1` is the same thing as `a = a - 1`
- we can also do `a--`
- `a *= 1` is the same thing as `a = a * 1`
- `a /= 1` is the same thing as `a = a / 1`
- `a %= 1` is the same thing as `a = a % 1`
- CED: "The use of increment and decrement operators in the prefix form
(i.e., `++x`) and inside other expressions (i.e., `arr[x++]`) is outside the scope
of this course and the AP Exam."
- casting
- we can cast a variable to another data type using this syntax:
`(datatype) variable`
- we can round a double by doing `(int) variable + 0.5` or `(int)
variable - 0.5` if variable is negative
- example: [[AP CSA Code Examples#Casting]]
- overflow
- when a byte, short, int, or long overflows they will wrap around
- integers
- the minimum and maximum integer value are stored in
`Integer.MIN_VALUE` and `Integer.MAX_VALUE` and are respectively `- 2 147 483 648`
and `2 147 483 647`
- when you go above that number, it "wraps around" so
`Integer.MAX_VALUE + 1` will be equal to `Integer.MIN_VALUE` and vice versa
- floats and doubles don't "wrap around", they go to `Infinity` or `-
Infinity`