Statements run one after another, top to bottom — the default flow.
Choose between paths: if, if…else, switch (Ch.4).
Repeat a block: while, for (Ch.4), do…while (Ch.4).
if only runs when trueif…else covers both cases{} group multiple statements into one blockLoop runs a known, fixed number of times using a counter variable.
Loop runs an unknown number of times, until a special "sentinel" input value ends it.
Nesting = placing one control statement inside another (e.g., an if inside a while) to model more complex logic like pass/fail counters.
| Compound | Equivalent |
|---|---|
c += 3 | c = c + 3 |
c -= 3 | c = c - 3 |
c *= 3 | c = c * 3 |
c /= 3 | c = c / 3 |
c %= 3 | c = c % 3 |
++c — increments first, then uses the valuec++ — uses the value first, then increments--c and c--byte, short, int, long — whole numbersfloat, double — decimal numberschar — single characterboolean — true / falseint/long have a max size. Java's BigInteger class (java.math) represents integers of virtually unlimited size for calculations that overflow primitives.
| Method | Purpose |
|---|---|
add(other) | returns the sum as a new BigInteger |
subtract(other) | returns the difference |
multiply(other) | returns the product |
divide(other) | returns the quotient |
mod(other) | returns the remainder |
compareTo(other) | negative/zero/positive comparison result |
toString() | decimal String representation |
Note: BigInteger objects are immutable — every operation returns a brand-new object rather than modifying the original.