• Home
  • LLMs
  • Python
  • Docker
  • Kubernetes
  • Java
  • Maven
  • All
  • About
Java | Java Keywords
  1. Notes
  2. Primitive Data Types
  3. Type Declaration & Variables
  4. Access Modifiers & Visibility
  5. Inheritance & Polymorphism
  6. Object Creation & Reference
  7. Method & Field Modifiers
  8. Conditional Statements
  9. Loop Statements
  10. Jump Statements
  11. Exception Handling
  12. Code Organization
  13. Testing & Debugging

  1. Notes
    module, requires, and exports are reserved keywords in module declarations and cannot be used as regular identifiers anywhere in Java code.

    goto and const are reserved keywords and cannot be used as identifiers, although they are not currently used in Java.
  2. Primitive Data Types
    • boolean: Represents true/false values

    • char: Single 16-bit Unicode character

    • byte: 8-bit signed integer (-128 to 127)

    • short: 16-bit signed integer (-32,768 to 32,767)

    • int: 32-bit signed integer (-2³¹ to 2³¹-1)

    • long: 64-bit signed integer (-2⁶³ to 2⁶³-1)

    • float: 32-bit floating point

    • double: 64-bit floating point

  3. Type Declaration & Variables
    • void: Indicates that a method doesn't return any value

    • var: Local variable type inference (cannot be used for class/instance fields, method parameters, or return types)

    • enum: Defines a fixed set of constants

    • class: Declares a class

    • interface: Declares an interface

  4. Access Modifiers & Visibility
    • public: Accessible from anywhere

    • private: Accessible only within the same class

    • protected: Accessible within package and subclasses

  5. Inheritance & Polymorphism
    • extends: Class inheritance (single inheritance)

    • implements: Interface implementation (multiple inheritance of type)

    • abstract: Declares abstract classes/methods (cannot be instantiated)

    • final: Prevents inheritance (classes), overriding (methods), or reassignment (variables)

  6. Object Creation & Reference
    • new: Creates new object instances

    • this: Reference to current object instance

    • super: Reference to parent class

    • instanceof: Tests object type at runtime

  7. Method & Field Modifiers
    • static: Belongs to class rather than instance (shared among all objects)

    • native: Method implemented in platform-specific code (JNI)

    • volatile: Ensures variable visibility across threads (prevents caching)

    • transient: Excludes field from serialization

    • synchronized: Thread-safe method/block execution

    • strictfp: Ensures consistent floating-point calculations across platforms

  8. Conditional Statements
    • if: Conditional execution

    • else: Alternative execution path

    • switch: Multi-way branching

    • case: Individual switch cases

    • default: Default case in switch statements

  9. Loop Statements
    • for: Counter-controlled loop (traditional and enhanced for-each)

    • while: Condition-controlled loop (pre-test)

    • do: Condition-controlled loop (post-test)

  10. Jump Statements
    • continue: Skips current iteration, continues with next

    • break: Exits loops or switch statements

    • return: Exits method and optionally returns value

  11. Exception Handling
    • try: Defines block that may throw exceptions

    • catch: Handles specific exception types

    • finally: Always executes regardless of exceptions

    • throw: Explicitly throws an exception

    • throws: Declares exceptions that method may throw

  12. Code Organization
    • import: Imports classes/packages for use

    • package: Declares a package namespace

  13. Testing & Debugging
    • assert: Runtime assertions for debugging (must be enabled with -ea flag)

© 2025  mtitek