Lesson plan

Static import

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.…

Back to article

Article summary

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.…

Key claims

No claims recorded.

Discussion questions

  1. Summarise the article in your own words. Which single claim would you verify first, and why?
  2. Which claim in this article is most likely to be revised as the sources update? How would you check its current status?
  3. If two sources disagreed about one of these facts, what would you need in order to trust one over the other?

Bibliography

No sources recorded.

Key claims and bibliography are generated from the same tracked claims and sources as the article page.