Types, operators, conditions and loops

This part covers the language itself: variables and the eight primitives with final and var, the different number types and the overflow of an int read from a real run, the narrowing casts, the operators with their precedence and the bitwise ones, char as a UTF-16 code unit and boolean as a type of its own. Conditions follow, with the dangling else and the conditional operator, then the switch statement and the switch expression with arrow labels and yield, the two loops and the enhanced for with labelled break. The part ends with methods: overloading, arguments by value, int... varargs and recursion, with the stack a deep call fills.

2.1 Variables, types and final the eight primitives, their sizes and ranges, literals, var, final, default values of fields, scope Open 2.2 Numbers, overflow and casts integer division, int overflow from a real run, long, float against double, narrowing casts, Math Open 2.3 Operators and precedence arithmetic, %, compound assignment, comparison, short-circuit logic, bitwise and shifts, precedence Open 2.4 char, boolean and Unicode char as a UTF-16 code unit, escapes, Character methods, boolean as a type of its own Open 2.5 if, else and the ternary if and else if, blocks and the dangling else, the conditional operator, String comparison with equals Open 2.6 The switch statement case, break, fall-through read from a run, default, a menu Open 2.7 The switch expression arrow labels, yield, several constants per label, an exhaustive switch over an enum Open 2.8 while and do-while a sentinel loop, a loop that runs once, do-while against while, an input loop Open 2.9 for, for-each and labels the three-part for, the enhanced for, nested loops, labelled break and continue Open 2.10 Methods declaration, parameters, return, void, overloading, static against an instance method Open 2.11 Arguments, arrays and varargs pass by value, an array argument, int..., main(String[] args) Open 2.12 Recursion and the stack a base case, factorial, Fibonacci, the call stack, StackOverflowError from a real run Open

Lessons