1. 1. Prelude
    ❱
    1. 1.1. Asking for Help
    2. 1.2. Toy Problems
    3. 1.3. Lies
    4. 1.4. AI
    5. 1.5. Java
  2. 2. Getting Started
  3. 3. First Steps
    ❱
    1. 3.1. Comments
    2. 3.2. Semicolons
    3. 3.3. Formatting
    4. 3.4. Challenges
  4. 4. Local Variables
    ❱
    1. 4.1. Naming
    2. 4.2. Reassignment
    3. 4.3. Delayed Assignment
    4. 4.4. Types
    5. 4.5. Final Variables
    6. 4.6. Inferred Types
    7. 4.7. Challenges
  5. Data Types I
  6. 5. Booleans
    ❱
    1. 5.1. Not
    2. 5.2. And
    3. 5.3. Or
    4. 5.4. Operator Precedence
    5. 5.5. Challenges
  7. 6. Integers
    ❱
    1. 6.1. Integer Literals
    2. 6.2. Addition
    3. 6.3. Subtraction
    4. 6.4. Multiplication
    5. 6.5. Division
    6. 6.6. Remainder
    7. 6.7. Equality
    8. 6.8. Comparison
    9. 6.9. Chained Comparisons
    10. 6.10. Operator Precedence
    11. 6.11. Reassignment
    12. 6.12. Shorthands for Reassignment
    13. 6.13. Limits
    14. 6.14. Challenges
  8. 7. Floating Point Numbers
    ❱
    1. 7.1. Floating Point Literals
    2. 7.2. Accuracy
    3. 7.3. Addition
    4. 7.4. Subtraction
    5. 7.5. Multiplication
    6. 7.6. Division
    7. 7.7. Equality
    8. 7.8. Comparison
    9. 7.9. Shorthands for Reassignment
    10. 7.10. NaN
    11. 7.11. Positive and Negative Infinity
    12. 7.12. Square Root
    13. 7.13. Conversion to Integers
    14. 7.14. Conversion from Integers
    15. 7.15. Challenges
  9. 8. Characters
    ❱
    1. 8.1. Character Literals
    2. 8.2. Common Escape Sequences
    3. 8.3. Conversion to Integers
    4. 8.4. Conversion from Integers
    5. 8.5. Unicode
    6. 8.6. Challenges
  10. 9. Strings
    ❱
    1. 9.1. String Literals
    2. 9.2. Common Escape Sequences
    3. 9.3. The Empty String
    4. 9.4. Multiline String Literals
    5. 9.5. Concatenation
    6. 9.6. Equality
    7. 9.7. Length
    8. 9.8. Access Individual Characters
    9. 9.9. Challenges
  11. Interactive Programs
  12. 10. Standard Input
    ❱
    1. 10.1. Prompting
    2. 10.2. Interpreting Input
    3. 10.3. Integers
    4. 10.4. Floating Point Numbers
    5. 10.5. Other Types
    6. 10.6. Challenges
  13. Control Flow I
  14. 11. Branching Paths
    ❱
    1. 11.1. If
    2. 11.2. Nested Ifs
    3. 11.3. Else
    4. 11.4. Else If
    5. 11.5. Relation to Delayed Assignment
    6. 11.6. Scoped Variables
    7. 11.7. Conditional Operator
    8. 11.8. Boolean Expressions
    9. 11.9. Challenges
  15. 12. Loops
    ❱
    1. 12.1. While
    2. 12.2. Endless Loops
    3. 12.3. Break
    4. 12.4. Continue
    5. 12.5. Unreachable Code
    6. 12.6. Do While
    7. 12.7. Nested Loops
    8. 12.8. Labeled Break
    9. 12.9. Labeled Continue
    10. 12.10. Iteration
    11. 12.11. Counting Up
    12. 12.12. Counting Down
    13. 12.13. Iterate over a String
    14. 12.14. Challenges
  16. Projects
  17. 13. Prelude
  18. 14. Calorie Tracker
  19. Data Types II
  20. 15. Arrays
    ❱
    1. 15.1. Array Initializers
    2. 15.2. Length
    3. 15.3. Access Individual Elements
    4. 15.4. Set Individual Elements
    5. 15.5. Aliasing
    6. 15.6. Reassignment
    7. 15.7. Relation to Final Variables
    8. 15.8. Printing the Contents of an Array
    9. 15.9. Empty Array
    10. 15.10. Difference between Initializer and Literal
    11. 15.11. Initialization with new
    12. 15.12. Challenges
  21. Control Flow II
  22. 16. Loops II
    ❱
    1. 16.1. For
    2. 16.2. For Syntax
    3. 16.3. Counting Up and Down
    4. 16.4. Iterate over a String
    5. 16.5. Iterate over an Array
    6. 16.6. Comparison to while
    7. 16.7. i
    8. 16.8. Break
    9. 16.9. Continue
    10. 16.10. Delayed Assignment
    11. 16.11. Inferred Types
    12. 16.12. Empty Initializers
    13. 16.13. Empty Expressions
    14. 16.14. Empty Statements
    15. 16.15. Final Variables
    16. 16.16. Labeled Break
    17. 16.17. Labeled Continue
    18. 16.18. Drawing Right Triangles
    19. 16.19. Drawing Isosceles Triangles
    20. 16.20. Challenges
  23. Projects
  24. 17. ASCII Art Generator
  25. Code Structure
  26. 18. Methods
    ❱
    1. 18.1. Declaration
    2. 18.2. Invocation
    3. 18.3. Scope
    4. 18.4. main
    5. 18.5. Challenges
  27. 19. Arguments
    ❱
    1. 19.1. Declaration
    2. 19.2. Invocation with Arguments
    3. 19.3. Reassignment
    4. 19.4. Final Arguments
    5. 19.5. Aliasing
    6. 19.6. Overloading
    7. 19.7. Inferred Types
    8. 19.8. Challenges
  28. 20. Return Values
    ❱
    1. 20.1. Declaration
    2. 20.2. Return Statement
    3. 20.3. Exhaustiveness
    4. 20.4. void
    5. 20.5. Return in void methods
    6. 20.6. Conversion
    7. 20.7. Unreachable Statements
    8. 20.8. Challenges
  29. Data Types III
  30. 21. null
    ❱
    1. 21.1. Null as Absence
    2. 21.2. Null as Unknown
    3. 21.3. Checking for null
    4. 21.4. NullPointerException
    5. 21.5. Challenges
  31. 22. Boxed Primitives
    ❱
    1. 22.1. Integer
    2. 22.2. Double
    3. 22.3. Character
    4. 22.4. Boolean
    5. 22.5. Unboxing Conversion
    6. 22.6. Boxing Conversion
    7. 22.7. Arrays of Boxed Primitives
    8. 22.8. Challenges
  32. 23. Arrays II
    ❱
    1. 23.1. Initializion with Size
    2. 23.2. Default Values
    3. 23.3. Populate Arrays
    4. 23.4. Challenges
  33. Code Structure II
  34. 24. Classes
    ❱
    1. 24.1. The meaning of the word Class
    2. 24.2. Class Declaration
    3. 24.3. Naming
    4. 24.4. Instances
    5. 24.5. Fields
    6. 24.6. Field Initialization
    7. 24.7. Field Access
    8. 24.8. Field Default Values
    9. 24.9. Aliasing
    10. 24.10. Return Multiple Values
    11. 24.11. Challenges
  35. 25. Instance Methods
    ❱
    1. 25.1. Invocation
    2. 25.2. Arguments
    3. 25.3. Field Access
    4. 25.4. Field Updates
    5. 25.5. Derived Values
    6. 25.6. Invoke Other Methods
    7. 25.7. this
    8. 25.8. Disambiguation
    9. 25.9. Clarity
    10. 25.10. Challenges
  36. Projects
  37. 26. Point of Sale System
  38. Data Types IV
  39. 27. Enums
    ❱
    1. 27.1. Declaration
    2. 27.2. Variants
    3. 27.3. Naming
    4. 27.4. Usage
    5. 27.5. Equality
    6. 27.6. Comparison to boolean
    7. 27.7. Challenges
  40. 28. Strings II
    ❱
    1. 28.1. lowercase
    2. 28.2. UPPERCASE
    3. 28.3. Equality ignoring case
    4. 28.4. Check if empty
    5. 28.5. Check if blank
    6. 28.6. Strip extra whitespace
    7. 28.7. Challenges
  41. Control Flow III
  42. 29. Exceptions
    ❱
    1. 29.1. throw
    2. 29.2. Messages
    3. 29.3. Stack Traces
    4. 29.4. try/catch
    5. 29.5. Challenges
  43. 30. Switch
    ❱
    1. 30.1. Case and Default
    2. 30.2. Strings
    3. 30.3. ints
    4. 30.4. Enums
    5. 30.5. Omitted Default
    6. 30.6. Combining Cases
    7. 30.7. null
    8. 30.8. Exhaustiveness
    9. 30.9. Challenges
  44. Interactive Programs II
  45. 31. Standard Input II
    ❱
    1. 31.1. Reprompting
    2. 31.2. Enums
    3. 31.3. Delayed Assignment
    4. 31.4. Leniency
    5. 31.5. Aggregating Data
    6. 31.6. Challenges
  46. Code Structure III
  47. 32. Constructors
    ❱
    1. 32.1. Declaration
    2. 32.2. The Default Constructor
    3. 32.3. Arguments
    4. 32.4. Final Fields
    5. 32.5. Invariants
    6. 32.6. Overloads
    7. 32.7. Delegation
    8. 32.8. Challenges
  48. 33. Global Fields
    ❱
    1. 33.1. Default Values
    2. 33.2. Final Fields
    3. 33.3. Field Access
    4. 33.4. Inferred Types
    5. 33.5. Challenges
  49. Concepts
  50. 34. Code is Read more than Written
    ❱
    1. 34.1. Meaning
    2. 34.2. Implications
    3. 34.3. Information Density
    4. 34.4. Audience
    5. 34.5. Practice
  51. The Computing Environment
  52. 35. Hardware
    ❱
    1. 35.1. CPU
    2. 35.2. RAM
    3. 35.3. Hard Drives
    4. 35.4. Motherboard
  53. 36. Operating Systems
    ❱
    1. 36.1. Personal Computers
    2. 36.2. Servers
    3. 36.3. Mobile Phones
    4. 36.4. Game Consoles
    5. 36.5. Abstractions
    6. 36.6. Defaults
  54. 37. The Terminal
    ❱
    1. 37.1. Bash
    2. 37.2. Windows Subsystem for Linux
    3. 37.3. Chromebooks and School Computers
    4. 37.4. Commands
    5. 37.5. Directories
    6. 37.6. Listing Files
    7. 37.7. Creating Directories
    8. 37.8. Changing Directories
    9. 37.9. Creating Files
    10. 37.10. Run Java Programs
    11. 37.11. Getting Used to it
  55. Control Flow IV
  56. 38. Exceptions II
    ❱
    1. 38.1. Checked Exceptions
    2. 38.2. Unchecked Exceptions
    3. 38.3. throws
    4. 38.4. Propagating Exceptions
    5. 38.5. Exception
    6. 38.6. RuntimeException
    7. 38.7. Rethrowing Exceptions
    8. 38.8. main
    9. 38.9. Challenges
  57. 39. Switch II
    ❱
    1. 39.1. Yield
    2. 39.2. Omitted Yield
    3. 39.3. Exhaustiveness
    4. 39.4. Return a Switch
    5. 39.5. Challenges
  58. Code Structure IV
  59. 40. Multi-File Programs
    ❱
    1. 40.1. The Sources folder
    2. 40.2. The Main file
    3. 40.3. A Second file
    4. 40.4. File names
    5. 40.5. The Anonymous Main Class
    6. 40.6. Global Fields
    7. 40.7. Challenges
  60. 41. Visibility
    ❱
    1. 41.1. Private Methods
    2. 41.2. Private Fields
    3. 41.3. Invariants
    4. 41.4. Accessors
    5. 41.5. Getters and Setters
    6. 41.6. Challenges
  61. 42. Static Fields
    ❱
    1. 42.1. Declaration
    2. 42.2. Initialization
    3. 42.3. Usage
    4. 42.4. Constants
    5. 42.5. Controversy
    6. 42.6. Naming
    7. 42.7. Challenges
  62. 43. Static Methods
    ❱
    1. 43.1. Declaration
    2. 43.2. Scope
    3. 43.3. Naming
    4. 43.4. Usage
    5. 43.5. Math
    6. 43.6. Factories
    7. 43.7. Challenges
  63. Data Structures & Algorithms
  64. 44. Growable Arrays
    ❱
    1. 44.1. Concept
    2. 44.2. Simple Implementation
    3. 44.3. Usage
    4. 44.4. Performance Problems
    5. 44.5. Performance Solutions
    6. 44.6. Optimized Implementation
    7. 44.7. Challenges
  65. Interactive Programs II
  66. 45. Command Line Arguments
    ❱
    1. 45.1. Accessing Arguments
    2. 45.2. Conventions
    3. 45.3. Challenges
  67. Code Structure V
  68. 46. Inner Classes
    ❱
    1. 46.1. Type
    2. 46.2. Instances
    3. 46.3. New Operator
    4. 46.4. Scope
    5. 46.5. Disambiguation
    6. 46.6. The anonymous main class
    7. 46.7. Static Inner Classes
    8. 46.8. Private Inner Classes
    9. 46.9. Challenges
  69. 47. Packages
    ❱
    1. 47.1. Declaration
    2. 47.2. Visibility
    3. 47.3. Public Classes
    4. 47.4. Fully Qualified Class Name
    5. 47.5. Import
    6. 47.6. The Default Package
    7. 47.7. The Anonymous Main Class
    8. 47.8. Public Methods
    9. 47.9. Package-Private Methods
    10. 47.10. Public Fields
    11. 47.11. Package-Private Fields
    12. 47.12. The Default Constructor
    13. 47.13. Public Constructors
    14. 47.14. Package-Private Constructors
    15. 47.15. Subpackages
    16. 47.16. Reverse Domain Name Notation
    17. 47.17. Challenges
  70. Data Types IV
  71. 48. Records
    ❱
    1. 48.1. Declaration
    2. 48.2. The Canonical Constructor
    3. 48.3. Component Accessors
    4. 48.4. Component Accessor Visibility
    5. 48.5. Printing a Record
    6. 48.6. Check for Equality
    7. 48.7. Return Multiple Values
    8. 48.8. Shorthand
    9. 48.9. Challenges
  72. 49. Integers II
    ❱
    1. 49.1. Integer from a String
    2. 49.2. Integer to a String
    3. 49.3. Base 16 Integer Literals
    4. 49.4. Integer from a Base 16 String
    5. 49.5. Integer to a Base 16 String
    6. 49.6. Underscores in Integer Literals
    7. 49.7. Challenges
  73. Interactive Programs III
  74. 50. Files
    ❱
    1. 50.1. Paths
    2. 50.2. IOException
    3. 50.3. UncheckedIOException
    4. 50.4. Write to a File
    5. 50.5. Read from a File
    6. 50.6. Create a Folder
    7. 50.7. Challenges
  75. Projects
  76. 51. Data Visualization
  77. Code Structure VI
  78. 52. Object
    ❱
    1. 52.1. Subtypes
    2. 52.2. instanceof
    3. 52.3. toString
    4. 52.4. Override toString
    5. 52.5. @Override
    6. 52.6. equals and hashCode
    7. 52.7. Override equals and hashCode
    8. 52.8. Challenges
  79. 53. Generics
    ❱
    1. 53.1. Type Variables
    2. 53.2. Naming
    3. 53.3. Instantiation
    4. 53.4. Inference
    5. 53.5. Soundness
    6. 53.6. Raw Types
    7. 53.7. Challenges
  80. 54. Interfaces
    ❱
    1. 54.1. Interface Declaration
    2. 54.2. Implementation
    3. 54.3. @Override
    4. 54.4. Naming
    5. 54.5. Subtypes
    6. 54.6. Multiple Implementations
    7. 54.7. Challenges
  81. Data Types V
  82. 55. Time
    ❱
    1. 55.1. Instant
    2. 55.2. Duration
    3. 55.3. LocalDate
    4. 55.4. LocalTime
    5. 55.5. LocalDateTime
    6. 55.6. Time Zones
    7. 55.7. ZonedDateTime
    8. 55.8. OffsetDateTime
    9. 55.9. Date
    10. 55.10. Challenges
  83. 56. ArrayList
    ❱
    1. 56.1. Ubiquity
    2. 56.2. Add an item
    3. 56.3. Size
    4. 56.4. Get an item
    5. 56.5. Loop over items
    6. 56.6. Set an item
    7. 56.7. Remove an item
    8. 56.8. Challenges
  84. 57. HashMap
    ❱
    1. 57.1. Filing Cabinets
    2. 57.2. Keys and Values
    3. 57.3. Put Items
    4. 57.4. Get Items
    5. 57.5. Hash Functions
    6. 57.6. Hash Collision
    7. 57.7. Hash Distribution
    8. 57.8. Reference Based Identity
    9. 57.9. Value Based Identity
    10. 57.10. Appropriate Keys
    11. 57.11. Ubiquity
    12. 57.12. Challenges
  85. Concepts II
  86. 58. Hyrum's Law
    ❱
    1. 58.1. Authority
    2. 58.2. Validity
    3. 58.3. Emergent Properties
    4. 58.4. Importance
  87. Control Flow V
  88. 59. Switch III
    ❱
    1. 59.1. break
    2. 59.2. fallthrough
    3. 59.3. return
    4. 59.4. default
    5. 59.5. yield
  89. 60. Recursion
    ❱
    1. 60.1. Disclaimer
    2. 60.2. Base Case
    3. 60.3. Comparison to Delegation
    4. 60.4. Comparison to Loops
    5. 60.5. Counting Down
    6. 60.6. Accumulators
    7. 60.7. Recurse Over a String
    8. 60.8. Recurse Over an Array
  90. 61. Loops III
    ❱
    1. 61.1. For-each loops
    2. 61.2. Arrays
    3. 61.3. Iterable and Iterator
    4. 61.4. ArrayList
    5. 61.5. String
    6. 61.6. Concurrent Modifications
    7. 61.7. Inferred Types
  91. Concepts II
  92. 62. Encapsulation
    ❱
    1. 62.1. Implementation Details
    2. 62.2. Implicit Interfaces
    3. 62.3. Methods
    4. 62.4. Classes
    5. 62.5. Abstraction
    6. 62.6. Coupling
    7. 62.7. Leaky Abstractions
    8. 62.8. Information Hiding
  93. Data Types VI
  94. 63. Collections
    ❱
    1. 63.1. List
    2. 63.2. Map
    3. 63.3. Set
    4. 63.4. Arrays
    5. 63.5. UnsupportedOperationException
    6. 63.6. Factories
    7. 63.7. Specificity
  95. 64. Multi-Dimensional Arrays
    ❱
    1. 64.1. Declaration
    2. 64.2. Array Initializers
    3. 64.3. Initialization with new
    4. 64.4. Access Individual Elements
    5. 64.5. Set Individual Elements
    6. 64.6. Initialization with Size
    7. 64.7. Default Values
    8. 64.8. Populate Values
    9. 64.9. Ragged Arrays
  96. Metaprogramming
  97. 65. Reflection
    ❱
    1. 65.1. Class Objects
    2. 65.2. Get all Fields
    3. 65.3. Get a Field
    4. 65.4. Read from a Field
    5. 65.5. Write to a Field
    6. 65.6. Get all Methods
    7. 65.7. Get a Method
    8. 65.8. Invoke a Method
    9. 65.9. Get a Constructor
    10. 65.10. Get all Constructors
    11. 65.11. Invoke a Constructor
  98. 66. Annotations
    ❱
    1. 66.1. Declaration
    2. 66.2. Usage
    3. 66.3. Elements
    4. 66.4. Usage with Elements
    5. 66.5. Defaults
    6. 66.6. @Target
    7. 66.7. @Retention
    8. 66.8. Reflective Access
    9. 66.9. @Override
  99. Code Structure VII
  100. 67. Interfaces II
    ❱
    1. 67.1. Default Methods
    2. 67.2. Interface Extension
    3. 67.3. Static Methods
    4. 67.4. Static Fields
  101. 68. Class Extension
    ❱
    1. 68.1. Extend a Class
    2. 68.2. Inheritance
    3. 68.3. Override
    4. 68.4. Protected
    5. 68.5. Abstract Classes
    6. 68.6. Abstract Methods
    7. 68.7. Relation to Interfaces
    8. 68.8. Relation to Encapsulation
    9. 68.9. Final Classes
  102. Data Types VII
  103. 69. Niche Numerics
    ❱
    1. 69.1. byte
    2. 69.2. short
    3. 69.3. long
    4. 69.4. Unsigned Operations
    5. 69.5. float
  104. Projects
  105. 70. Hot Cross Buns
  106. Code Structure VIII
  107. 71. Modules
    ❱
    1. 71.1. Declaration
    2. 71.2. Restrictions
    3. 71.3. Exports
    4. 71.4. Integrity
    5. 71.5. java.base
    6. 71.6. The Unnamed Module
    7. 71.7. Module Imports
    8. 71.8. Multi-Module Directory Layout
  108. 72. Lambdas
    ❱
    1. 72.1. Functional Interfaces
    2. 72.2. @FunctionalInterface
    3. 72.3. Lambda Expressions
    4. 72.4. Method References
    5. 72.5. Runnable
    6. 72.6. Function
    7. 72.7. Relation to Checked Exceptions
  109. 73. Streams
    ❱
    1. 73.1. map
    2. 73.2. filter
    3. 73.3. Collectors
    4. 73.4. toList
    5. 73.5. mapMulti
    6. 73.6. Gatherers
  110. Sharing Code
  111. 74. Compilation
    ❱
    1. 74.1. javac
    2. 74.2. --release
  112. 75. Packaging
    ❱
    1. 75.1. jar
    2. 75.2. --main-class
  113. 76. Documentation
    ❱
    1. 76.1. javadoc
    2. 76.2. Documentation Comments
  114. 77. Distribution
    ❱
    1. 77.1. jlink
  115. 78. 🚧 (More Chapters Planned) 🚧

Modern Java

Java