1. 1. Prelude
    ❱
    1. 1.1. Asking for Help
    2. 1.2. Toy Problems
    3. 1.3. Lies
  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. And
    2. 5.2. Or
    3. 5.3. Not
    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. Control Flow I
  12. 10. Branching Paths
    ❱
    1. 10.1. If
    2. 10.2. Else
    3. 10.3. Nested Ifs
    4. 10.4. Else If
    5. 10.5. Relation to Delayed Assignment
    6. 10.6. Conditional Operator
    7. 10.7. Boolean Expressions
    8. 10.8. Challenges
  13. 11. Loops
    ❱
    1. 11.1. While
    2. 11.2. Endless Loops
    3. 11.3. Break
    4. 11.4. Continue
    5. 11.5. Unreachable Code
    6. 11.6. Do While
    7. 11.7. Nested Loops
    8. 11.8. Labeled Break
    9. 11.9. Labeled Continue
    10. 11.10. Iteration
    11. 11.11. Counting Up
    12. 11.12. Counting Down
    13. 11.13. Iterate over a String
    14. 11.14. Challenges
  14. Data Types II
  15. 12. Arrays
    ❱
    1. 12.1. Array Initializers
    2. 12.2. Length
    3. 12.3. Access Individual Elements
    4. 12.4. Set Individual Elements
    5. 12.5. Aliasing
    6. 12.6. Reassignment
    7. 12.7. Relation to Final Variables
    8. 12.8. Printing the Contents of an Array
    9. 12.9. Empty Array
    10. 12.10. Difference between Initializer and Literal
    11. 12.11. Challenges
  16. Control Flow II
  17. User Defined Types
  18. 13. Classes
    ❱
    1. 13.1. Primitive Classes
    2. 13.2. Reference Classes
    3. 13.3. null
    4. 13.4. Class Declaration
    5. 13.5. Naming
  19. 14. Fields
    ❱
    1. 14.1. Default Values
  20. 15. Methods
    ❱
    1. 15.1. Arguments
    2. 15.2. Return Values
    3. 15.3. void
  21. 16. Constructors

Modern Java

Integers

An integer is any number in the set { ..., -2, -1, 0, 1, 2, ... }.

int x = 1;
int y = 8;
int z = -4;