- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Demonstrate Static Import in Java
Static import is a feature that was introduced in Java version 5 and above. It means that the fields and methods in a class can be used in the code without specifying their class if they are defined as public static.
A program that demonstrates this in Java is given as follows:
Example
import static java.lang.System.*; public class Demo { public static void main(String args[]) { out.println("Demonstration of Static Import in Java"); int a = 10; out.println("Value of a is: " + a); } }
Output
Demonstration of Static Import in Java Value of a is: 10
Now let us understand the above program.
The System class is not required in System.out.println() as static import is used for the java.lang package. So there is no need to specify the class System to use the out member field of the System class and the println method. A code snippet which demonstrates this is as follows:
out.println("Demonstration of Static Import in Java"); int a = 10; out.println("Value of a is: " + a);
- Related Articles
- What is static import in Java?
- Demonstrate static variables, methods and blocks in Java
- What are the differences between import and static import statements in Java?
- Static import the Math Class Methods in Java
- Use static Import for sqrt() and pow() methods in class Math in Java
- Demonstrate thread priorities in Java
- Demonstrate the clone() method in Java
- Demonstrate Private access modifier in Java
- Demonstrate constructors in a Multilevel Hierarchy in Java
- Create and demonstrate an immutable collection in Java
- Demonstrate getting the immediate superclass information in Java
- Static class in Java
- Static variables in Java
- static Keyword in Java
- What does import Java.util.* in Java do?

Advertisements