1. 1. Prelude
    ❱
    1. 1.1. Asking for Help
    2. 1.2. Toy Problems
    3. 1.3. Lies
    4. 1.4. AI
  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. Interactive Programs II
  17. 13. Standard Input II
    ❱
    1. 13.1. Prompting
    2. 13.2. Interpreting Input
    3. 13.3. Reprompting
    4. 13.4. Leniency
    5. 13.5. Delayed Assignment
  18. Projects
  19. 14. Prelude
  20. 15. Calorie Tracker
  21. Data Types II
  22. 16. Arrays
    ❱
    1. 16.1. Array Initializers
    2. 16.2. Length
    3. 16.3. Access Individual Elements
    4. 16.4. Set Individual Elements
    5. 16.5. Aliasing
    6. 16.6. Reassignment
    7. 16.7. Relation to Final Variables
    8. 16.8. Printing the Contents of an Array
    9. 16.9. Empty Array
    10. 16.10. Difference between Initializer and Literal
    11. 16.11. Initialization with new
    12. 16.12. Challenges
  23. Control Flow II
  24. 17. Loops II
    ❱
    1. 17.1. For
    2. 17.2. For Syntax
    3. 17.3. Counting Up and Down
    4. 17.4. Iterate over a String
    5. 17.5. Iterate over an Array
    6. 17.6. Comparison to while
    7. 17.7. i
    8. 17.8. Break
    9. 17.9. Continue
    10. 17.10. Delayed Assignment
    11. 17.11. Inferred Types
    12. 17.12. Empty Initializers
    13. 17.13. Empty Expressions
    14. 17.14. Empty Statements
    15. 17.15. Final Variables
    16. 17.16. Labeled Break
    17. 17.17. Labeled Continue
    18. 17.18. Drawing Right Triangles
    19. 17.19. Drawing Isosceles Triangles
    20. 17.20. Challenges
  25. Projects
  26. 18. ASCII Art Generator
  27. Code Structure
  28. 19. Methods
    ❱
    1. 19.1. Declaration
    2. 19.2. Invocation
    3. 19.3. Scope
    4. 19.4. main
    5. 19.5. Challenges
  29. 20. Arguments
    ❱
    1. 20.1. Declaration
    2. 20.2. Invocation with Arguments
    3. 20.3. Reassignment
    4. 20.4. Final Arguments
    5. 20.5. Aliasing
    6. 20.6. Overloading
    7. 20.7. Inferred Types
    8. 20.8. Challenges
  30. 21. Return Values
    ❱
    1. 21.1. Declaration
    2. 21.2. Return Statement
    3. 21.3. Exhaustiveness
    4. 21.4. void
    5. 21.5. Return in void methods
    6. 21.6. Conversion
    7. 21.7. Unreachable Statements
    8. 21.8. Challenges
  31. Data Types III
  32. 22. null
    ❱
    1. 22.1. Null as Absence
    2. 22.2. Null as Unknown
    3. 22.3. Checking for null
    4. 22.4. NullPointerException
    5. 22.5. Challenges
  33. 23. Boxed Primitives
    ❱
    1. 23.1. Integer
    2. 23.2. Double
    3. 23.3. Character
    4. 23.4. Boolean
    5. 23.5. Unboxing Conversion
    6. 23.6. Boxing Conversion
    7. 23.7. Arrays of Boxed Primitives
    8. 23.8. Challenges
  34. 24. Arrays II
    ❱
    1. 24.1. Initializion with Size
    2. 24.2. Default Values
    3. 24.3. Populate Arrays
    4. 24.4. Challenges
  35. Projects
  36. 25. Point of Sale System
  37. Code Structure II
  38. 26. Classes
    ❱
    1. 26.1. The meaning of the word Class
    2. 26.2. Class Declaration
    3. 26.3. Naming
    4. 26.4. Instances
    5. 26.5. Fields
    6. 26.6. Field Initialization
    7. 26.7. Field Access
    8. 26.8. Field Default Values
    9. 26.9. Aliasing
    10. 26.10. Return Multiple Values
    11. 26.11. Challenges
  39. 27. Instance Methods
    ❱
    1. 27.1. Invocation
    2. 27.2. Arguments
    3. 27.3. Field Access
    4. 27.4. Field Updates
    5. 27.5. Derived Values
    6. 27.6. Invoke Other Methods
    7. 27.7. this
    8. 27.8. Disambiguation
    9. 27.9. Clarity
    10. 27.10. Challenges
  40. Interactive Programs III
  41. 28. Standard Input III
    ❱
    1. 28.1. Transporting Data
  42. Projects II
  43. 29. Monte Carlo Sampling
  44. Data Types IV
  45. 30. Enums
    ❱
    1. 30.1. Declaration
    2. 30.2. Variants
    3. 30.3. Naming
    4. 30.4. Usage
    5. 30.5. Equality
    6. 30.6. Comparison to boolean
    7. 30.7. Challenges
  46. 31. Strings II
    ❱
    1. 31.1. lowercase
    2. 31.2. UPPERCASE
    3. 31.3. Equality ignoring case
    4. 31.4. Check if empty
    5. 31.5. Check if blank
    6. 31.6. Strip extra whitespace
    7. 31.7. Challenges
  47. Control Flow III
  48. 32. Exceptions
    ❱
    1. 32.1. throw
    2. 32.2. Messages
    3. 32.3. Stack Traces
    4. 32.4. try/catch
    5. 32.5. Challenges
  49. 33. Switch
    ❱
    1. 33.1. Case and Default
    2. 33.2. Strings
    3. 33.3. ints
    4. 33.4. Enums
    5. 33.5. Omitted Default
    6. 33.6. Exhaustiveness
    7. 33.7. Combining Cases
    8. 33.8. null
    9. 33.9. Challenges
  50. Code Structure III
  51. 34. Constructors
    ❱
    1. 34.1. Declaration
    2. 34.2. The Default Constructor
    3. 34.3. Arguments
    4. 34.4. Final Fields
    5. 34.5. Invariants
    6. 34.6. Overloads
    7. 34.7. Delegation
    8. 34.8. Challenges
  52. 35. Global Fields
    ❱
    1. 35.1. Default Values
    2. 35.2. Final Fields
    3. 35.3. Field Access
    4. 35.4. Inferred Types
    5. 35.5. Challenges
  53. Concepts
  54. 36. Code is Read more than Written
    ❱
    1. 36.1. Meaning
    2. 36.2. Implications
    3. 36.3. Information Density
    4. 36.4. Audience
    5. 36.5. Practice
  55. The Computing Environment
  56. 37. Hardware
    ❱
    1. 37.1. CPU
    2. 37.2. RAM
    3. 37.3. Hard Drives
    4. 37.4. Motherboard
  57. 38. Operating Systems
    ❱
    1. 38.1. Personal Computers
    2. 38.2. Servers
    3. 38.3. Mobile Phones
    4. 38.4. Game Consoles
    5. 38.5. Abstractions
    6. 38.6. Defaults
  58. 39. The Terminal
    ❱
    1. 39.1. Bash
    2. 39.2. Windows Subsystem for Linux
    3. 39.3. Chromebooks and School Computers
    4. 39.4. Commands
    5. 39.5. Directories
    6. 39.6. Listing Files
    7. 39.7. Creating Directories
    8. 39.8. Changing Directories
    9. 39.9. Creating Files
    10. 39.10. Run Java Programs
    11. 39.11. Getting Used to it
  59. Control Flow IV
  60. 40. Exceptions II
    ❱
    1. 40.1. Checked Exceptions
    2. 40.2. Unchecked Exceptions
    3. 40.3. throws
    4. 40.4. Propagating Exceptions
    5. 40.5. Rethrowing Exceptions
    6. 40.6. Exception
    7. 40.7. RuntimeException
    8. 40.8. main
  61. 41. Switch II
    ❱
    1. 41.1. Yield
    2. 41.2. Omitted Yield
    3. 41.3. Exhaustiveness
    4. 41.4. Return a Switch
  62. Code Structure IV
  63. 42. Multi-File Programs
    ❱
    1. 42.1. The Sources folder
    2. 42.2. The Main file
    3. 42.3. A Second file
    4. 42.4. File names
    5. 42.5. The Anonymous Main Class
    6. 42.6. Global Fields
  64. 43. Visibility
    ❱
    1. 43.1. Private Methods
    2. 43.2. Private Fields
    3. 43.3. Invariants
    4. 43.4. Accessors
    5. 43.5. Getters and Setters
  65. 44. Static Fields
    ❱
    1. 44.1. Declaration
    2. 44.2. Initialization
    3. 44.3. Usage
    4. 44.4. Constants
    5. 44.5. Controversy
    6. 44.6. Naming
  66. 45. Static Methods
    ❱
    1. 45.1. Declaration
    2. 45.2. Scope
    3. 45.3. Naming
    4. 45.4. Usage
    5. 45.5. Math
    6. 45.6. Factories
  67. Data Structures & Algorithms
  68. 46. Growable Arrays
    ❱
    1. 46.1. Concept
    2. 46.2. Simple Implementation
    3. 46.3. Usage
    4. 46.4. Performance Problems
    5. 46.5. Performance Solutions
    6. 46.6. Optimized Implementation
  69. Interactive Programs II
  70. 47. Command Line Arguments
    ❱
    1. 47.1. Accessing Arguments
    2. 47.2. Conventions
  71. Code Structure V
  72. 48. Inner Classes
    ❱
    1. 48.1. Type
    2. 48.2. Instances
    3. 48.3. New Operator
    4. 48.4. Scope
    5. 48.5. Disambiguation
    6. 48.6. The anonymous main class
    7. 48.7. Static Inner Classes
    8. 48.8. Private Inner Classes
  73. 49. Packages
    ❱
    1. 49.1. Declaration
    2. 49.2. Visibility
    3. 49.3. Public Classes
    4. 49.4. Fully Qualified Class Name
    5. 49.5. Import
    6. 49.6. The Default Package
    7. 49.7. The Anonymous Main Class
    8. 49.8. Public Methods
    9. 49.9. Package-Private Methods
    10. 49.10. Public Fields
    11. 49.11. Package-Private Fields
    12. 49.12. The Default Constructor
    13. 49.13. Public Constructors
    14. 49.14. Package-Private Constructors
    15. 49.15. Subpackages
    16. 49.16. Reverse Domain Name Notation
  74. Data Types IV
  75. 50. Records
    ❱
    1. 50.1. Declaration
    2. 50.2. The Canonical Constructor
    3. 50.3. Component Accessors
    4. 50.4. Component Accessor Visibility
    5. 50.5. Printing a Record
    6. 50.6. Check for Equality
    7. 50.7. Return Multiple Values
    8. 50.8. Shorthand
  76. 51. Integers II
    ❱
    1. 51.1. Integer from a String
    2. 51.2. Integer to a String
    3. 51.3. Base 16 Integer Literals
    4. 51.4. Integer from a Base 16 String
    5. 51.5. Integer to a Base 16 String
    6. 51.6. Underscores in Integer Literals
  77. Interactive Programs III
  78. 52. Files
    ❱
    1. 52.1. Paths
    2. 52.2. IOException
    3. 52.3. UncheckedIOException
    4. 52.4. Write to a File
    5. 52.5. Read from a File
    6. 52.6. Create a Folder
    7. 52.7. Challenges
  79. Projects
  80. 53. Journal Entries
  81. 54. Draw a Picture
  82. Code Structure VI
  83. 55. Object
    ❱
    1. 55.1. Subtypes
    2. 55.2. instanceof
    3. 55.3. toString
    4. 55.4. Override toString
    5. 55.5. @Override
    6. 55.6. equals and hashCode
    7. 55.7. Override equals and hashCode
  84. 56. Generics
    ❱
    1. 56.1. Type Variables
    2. 56.2. Naming
    3. 56.3. Instantiation
    4. 56.4. Inference
    5. 56.5. Soundness
    6. 56.6. Raw Types
  85. 57. Interfaces
    ❱
    1. 57.1. Interface Declaration
    2. 57.2. Implementation
    3. 57.3. @Override
    4. 57.4. Naming
    5. 57.5. Subtypes
    6. 57.6. Multiple Implementations
  86. Data Types V
  87. 58. Time
    ❱
    1. 58.1. Instant
    2. 58.2. Duration
    3. 58.3. LocalDate
    4. 58.4. LocalTime
    5. 58.5. LocalDateTime
    6. 58.6. Time Zones
    7. 58.7. ZonedDateTime
    8. 58.8. OffsetDateTime
    9. 58.9. Date
    10. 58.10. Challenges
  88. 59. ArrayList
    ❱
    1. 59.1. Ubiquity
    2. 59.2. Add an item
    3. 59.3. Size
    4. 59.4. Get an item
    5. 59.5. Loop over items
    6. 59.6. Set an item
    7. 59.7. Remove an item
  89. 60. HashMap
    ❱
    1. 60.1. Filing Cabinets
    2. 60.2. Keys and Values
    3. 60.3. Put Items
    4. 60.4. Get Items
    5. 60.5. Hash Functions
    6. 60.6. Hash Collision
    7. 60.7. Hash Distribution
    8. 60.8. Reference Based Identity
    9. 60.9. Value Based Identity
    10. 60.10. Appropriate Keys
    11. 60.11. Ubiquity
  90. Concepts II
  91. 61. Hyrum's Law
    ❱
    1. 61.1. Authority
    2. 61.2. Validity
    3. 61.3. Emergent Properties
    4. 61.4. Importance
  92. Control Flow V
  93. 62. Switch III
    ❱
    1. 62.1. break
    2. 62.2. fallthrough
    3. 62.3. return
    4. 62.4. default
    5. 62.5. yield
  94. 63. Recursion
    ❱
    1. 63.1. Disclaimer
    2. 63.2. Base Case
    3. 63.3. Comparison to Delegation
    4. 63.4. Comparison to Loops
    5. 63.5. Counting Down
    6. 63.6. Accumulators
    7. 63.7. Recurse Over a String
    8. 63.8. Recurse Over an Array
  95. 64. Loops III
    ❱
    1. 64.1. For-each loops
    2. 64.2. Arrays
    3. 64.3. Iterable and Iterator
    4. 64.4. ArrayList
    5. 64.5. String
    6. 64.6. Concurrent Modifications
    7. 64.7. Inferred Types
  96. Concepts II
  97. 65. Encapsulation
    ❱
    1. 65.1. Implementation Details
    2. 65.2. Implicit Interfaces
    3. 65.3. Methods
    4. 65.4. Classes
    5. 65.5. Abstraction
    6. 65.6. Coupling
    7. 65.7. Leaky Abstractions
    8. 65.8. Information Hiding
  98. Data Types VI
  99. 66. Collections
    ❱
    1. 66.1. List
    2. 66.2. Map
    3. 66.3. Set
    4. 66.4. Arrays
    5. 66.5. UnsupportedOperationException
    6. 66.6. Factories
    7. 66.7. Specificity
  100. 67. Multi-Dimensional Arrays
    ❱
    1. 67.1. Declaration
    2. 67.2. Array Initializers
    3. 67.3. Initialization with new
    4. 67.4. Access Individual Elements
    5. 67.5. Set Individual Elements
    6. 67.6. Initialization with Size
    7. 67.7. Default Values
    8. 67.8. Populate Values
    9. 67.9. Ragged Arrays
  101. Metaprogramming
  102. 68. Reflection
    ❱
    1. 68.1. Class Objects
    2. 68.2. Get all Fields
    3. 68.3. Get a Field
    4. 68.4. Read from a Field
    5. 68.5. Write to a Field
    6. 68.6. Get all Methods
    7. 68.7. Get a Method
    8. 68.8. Invoke a Method
    9. 68.9. Get a Constructor
    10. 68.10. Get all Constructors
    11. 68.11. Invoke a Constructor
  103. 69. Annotations
    ❱
    1. 69.1. Declaration
    2. 69.2. Usage
    3. 69.3. Elements
    4. 69.4. Usage with Elements
    5. 69.5. Defaults
    6. 69.6. @Target
    7. 69.7. @Retention
    8. 69.8. Reflective Access
    9. 69.9. @Override
  104. Code Structure VII
  105. 70. Interfaces II
    ❱
    1. 70.1. Default Methods
    2. 70.2. Interface Extension
    3. 70.3. Static Methods
    4. 70.4. Static Fields
  106. 71. Class Extension
    ❱
    1. 71.1. Extend a Class
    2. 71.2. Inheritance
    3. 71.3. Override
    4. 71.4. Protected
    5. 71.5. Abstract Classes
    6. 71.6. Abstract Methods
    7. 71.7. Relation to Interfaces
    8. 71.8. Relation to Encapsulation
    9. 71.9. Final Classes
  107. Data Types VII
  108. 72. Niche Numerics
    ❱
    1. 72.1. byte
    2. 72.2. short
    3. 72.3. long
    4. 72.4. Unsigned Operations
    5. 72.5. float
  109. Projects
  110. 73. Hot Cross Buns
  111. Code Structure VIII
  112. 74. Modules
    ❱
    1. 74.1. Declaration
    2. 74.2. Restrictions
    3. 74.3. Exports
    4. 74.4. Integrity
    5. 74.5. java.base
    6. 74.6. The Unnamed Module
    7. 74.7. Module Imports
    8. 74.8. Multi-Module Directory Layout
  113. 75. Lambdas
    ❱
    1. 75.1. Functional Interfaces
    2. 75.2. @FunctionalInterface
    3. 75.3. Lambda Expressions
    4. 75.4. Method References
    5. 75.5. Runnable
    6. 75.6. Function
    7. 75.7. Relation to Checked Exceptions
  114. 76. Streams
    ❱
    1. 76.1. map
    2. 76.2. filter
    3. 76.3. Collectors
    4. 76.4. toList
    5. 76.5. mapMulti
    6. 76.6. Gatherers
  115. Sharing Code
  116. 77. Compilation
    ❱
    1. 77.1. javac
    2. 77.2. --release
  117. 78. Packaging
    ❱
    1. 78.1. jar
    2. 78.2. --main-class
  118. 79. Documentation
    ❱
    1. 79.1. javadoc
    2. 79.2. Documentation Comments
  119. 80. Distribution
    ❱
    1. 80.1. jlink
  120. 81. 🚧 (More Chapters Planned) 🚧

Modern Java

Standard Input III