{
  "schema_version": "1.0",
  "codex": "thecodex.expert/coding",
  "type": "language-reference",
  "slug": "languages/java",
  "name": "Java",
  "section": "Languages",
  "canonical_definition": "Java is a statically typed, class-based, object-oriented programming language that compiles to platform-independent bytecode executed by the Java Virtual Machine (JVM), providing automatic memory management, true multi-threading, and a comprehensive standard library.",
  "confidence": "high",
  "last_verified": "2026-06-01",
  "url": "https://thecodex.expert/coding/languages/java/",
  "current_version": "Java 23 (September 2024)",
  "lts_version": "Java 21 (September 2023)",
  "created": "1995",
  "creator": "James Gosling (Sun Microsystems)",
  "typing": "static, strong",
  "execution": "compiled to JVM bytecode, JIT compiled by HotSpot",
  "memory_management": "garbage collected (G1, ZGC, Shenandoah)",
  "concurrency": "true multi-threading; virtual threads since Java 21 (Project Loom, JEP 444)",
  "paradigms": [
    "object-oriented",
    "procedural",
    "functional (Java 8+)"
  ],
  "notable_quirks": {
    "primitives_vs_objects": "int vs Integer; == compares references for objects, use .equals()",
    "type_erasure": "generics erased at runtime; cannot instanceof List<String>",
    "checked_exceptions": "must declare or catch IOException, SQLException etc.",
    "autoboxing": "automatic int<->Integer; has performance cost in hot paths",
    "string_immutability": "String is immutable; use StringBuilder for concatenation in loops",
    "java_javascript": "Java and JavaScript are completely unrelated despite similar names"
  },
  "version_milestones": {
    "Java 5 (2004)": "generics, autoboxing, enums, annotations, varargs",
    "Java 8 (2014)": "lambdas, Streams API, Optional, default methods",
    "Java 9 (2017)": "module system (Jigsaw), JShell REPL",
    "Java 14 (2020)": "records (preview), switch expressions",
    "Java 16 (2021)": "records stable, instanceof pattern matching",
    "Java 17 (2021)": "sealed classes, text blocks stable [LTS]",
    "Java 21 (2023)": "virtual threads (Project Loom), sequenced collections, pattern matching switch [LTS]",
    "Java 23 (2024)": "unnamed classes and instance main methods (preview)"
  },
  "sources": [
    {
      "num": 1,
      "citation": "Gosling, J. et al. (2021). The Java Language Specification, Java SE 17. Oracle. docs.oracle.com/javase/specs/.",
      "tier": 1
    },
    {
      "num": 2,
      "citation": "Bloch, J. (2018). Effective Java (3rd ed.). Addison-Wesley.",
      "tier": 1
    },
    {
      "num": 3,
      "citation": "JEP 444 \u2014 Virtual Threads. openjdk.org/jeps/444.",
      "tier": 1
    },
    {
      "num": 4,
      "citation": "Oracle. Java Platform SE Documentation. docs.oracle.com/en/java/javase/.",
      "tier": 1
    },
    {
      "num": 5,
      "citation": "Goetz, B. et al. (2006). Java Concurrency in Practice. Addison-Wesley.",
      "tier": 1
    }
  ]
}