{
  "id": "static-import-855166-8882f67edd904811",
  "slug": "static-import",
  "title": "Static import",
  "qid": "Q7604164",
  "lead": "Static import is a feature introduced in the Java programming language that allows members (fields and methods) which have been scoped within their container class as public static , to be used in Java code without specifying the class in which the field has been defined. This feature was introduced into the language in version 5.0. The feature provides a typesafe mechanism to include constants into code without having to reference the class that originally defined the field. It also helps to deprecate the practice of creating a constant interface (an interface that only defines constants then writing a class implementing that interface, which is considered an inappropriate use of interfaces. ) The mechanism can be used to reference individual members of a class: import static java.lang.Math.PI; import static java.lang.Math.pow; or all the static members of a class: import static java.lang.Math.*; For example, this class: public class HelloWorld { public static void main(String[] args) { System.out.println(\"Hello World!\"); System.out.println(\"Considering a circle with a diameter of 5 cm, it has\"); System.out.println(\"a circumference of \" + (Math.PI * 5) + \" cm\"); System.out.println(\"and an area of \" + (Math.PI * Math.pow(2.5, 2)) + \" sq.…",
  "body": "Static import is a feature introduced in the Java programming language that allows members (fields and methods) which have been scoped within their container class as public static , to be used in Java code without specifying the class in which the field has been defined. This feature was introduced into the language in version 5.0. The feature provides a typesafe mechanism to include constants into code without having to reference the class that originally defined the field. It also helps to deprecate the practice of creating a constant interface (an interface that only defines constants then writing a class implementing that interface, which is considered an inappropriate use of interfaces. ) The mechanism can be used to reference individual members of a class: import static java.lang.Math.PI; import static java.lang.Math.pow; or all the static members of a class: import static java.lang.Math.*; For example, this class: public class HelloWorld { public static void main(String[] args) { System.out.println(\"Hello World!\"); System.out.println(\"Considering a circle with a diameter of 5 cm, it has\"); System.out.println(\"a circumference of \" + (Math.PI * 5) + \" cm\"); System.out.println(\"and an area of \" + (Math.PI * Math.pow(2.5, 2)) + \" sq. cm\"); } } Can instead be written as: import static java.lang.Math.*; import static java.lang.System.out; public class HelloWorld { public static void main(String[] args) { out.println(\"Hello World!\"); out.println(\"Considering a circle with a diameter of 5 cm, it has\"); out.println(\"a circumference of \" + (PI * 5) + \" cm\"); out.println(\"and an area of \" + (PI * pow(2.5, 2)) + \" sq. cm\"); } } import static java.lang.Integer.*; import static java.lang.Long.*; public class HelloWorld { public static void main(String[] args) { System.out.println(MAX_VALUE); } } In this case, MAX_VALUE is ambiguous, as the MAX_VALUE field is an attribute of both java.lang.Integer and java.lang.Long . Prefixing the field with its class name will disambiguate the class from which MAX_VALUE is derived, but doing so makes the use of a static import redundant.",
  "categories": [
    "23144475",
    "23603337",
    "26157654",
    "26220375"
  ],
  "license": "CC BY-SA 4.0",
  "source_uri": "https://en.wikipedia.org/w/index.php?oldid=1178742661",
  "content_hash": "8882f67edd904811d1cf9a4a50e4b58ce33f446494487f81e1126e9e9b24f6f1",
  "created_at": 1792311698.6258442,
  "updated_at": 1696513944.0,
  "claims": [],
  "contradictions": [],
  "confidence": 0.6,
  "csl": {
    "id": "static-import-855166-8882f67edd904811",
    "type": "webpage",
    "title": "Static import",
    "author": [
      {
        "family": "Anticloud FZ LLE",
        "literal": "Anticloud FZ LLE"
      }
    ],
    "container-title": "encyclopegia.org",
    "publisher": "Anticloud FZ LLE",
    "publisher-place": "Dubai, United Arab Emirates",
    "URL": "https://encyclopegia.org/a/static-import",
    "issued": {
      "date-parts": [
        [
          2026,
          10,
          18
        ]
      ]
    },
    "accessed": {
      "date-parts": [
        [
          2026,
          11,
          19
        ]
      ]
    },
    "license": "CC BY-SA 4.0",
    "DOI": "eo1:static-import-855166-8882f67edd904811",
    "isBasedOn": "https://en.wikipedia.org/w/index.php?oldid=1178742661",
    "note": "Immutable snapshot static-import-855166-8882f67edd904811, content root 8882f67edd904811…"
  }
}