Static Import in Java

With Java static import feature, which was added in Java 5, you can access static members (fields and methods defined as public static) of a class without qualifying them with class name. How to use static import in Java Generally if you need to access any static member (static field…

Continue reading

Static Block in Java

Static block in Java is used to initialize the static variables (also known as class variables). To initialize instance variables there are constructors, where error handling or other logic can be used. To provide the same capability for class variables, there are static initialization blocks in Java. Syntax of Java…

Continue reading

Java ScheduledThreadPoolExecutor – Scheduling With ExecutorService

ScheduledThreadPoolExecutor in Java adds functionality to schedule commands to run after a given delay, or to execute periodically. Since ScheduledThreadPoolExecutor is an ExecutorService so it uses thread from a thread pool to execute tasks. Java ScheduledThreadPoolExecutor ScheduledThreadPoolExecutor class is part of Java Executor framework with in the Java concurrent API.…

Continue reading