Chapter 01: Building Blocks
Cheatsheet

Chapter 01 Cheatsheet

Main method parameter

  1. String[] args
  2. String options[]
  3. String... friends

Ordering elements in class

  1. Package
  2. Import
  3. Top-level type declaration
  4. Field declaration
  5. Method declaration

Primitives

  1. boolean: false
  2. byte: 0
  3. short: 0
  4. int: 0
  5. long: 0L
  6. float: 0.0f (without lowercase l or uppercase L, it will be treated as int)
  7. double: 0.0 (without lowercase f or uppercase f, it will be treated as double)
  8. char: \u0000

Garbage collection

  • When there is no reference to an object in a currently live thread
  • When there are no references pointing to the object
  • When all references to the object gone out of scope

❌ Invalid underscore position

  1. not at the start -> _1000.00
  2. not at the end -> 10000.00_
  3. not beside decimal -> 100_.00