Java Tutorial

how to measure method execution time in java

You can measure method execution time in java using the method System.nanoTime() or System.currentTimeMillis(). Put this method before and after the method or piece of code for which you want to measure the running time. Find the difference of the time you got before and after your code. The difference is the running time. Method […]

Abstract Class in Java with Purpose and Real Time Example

Learn the abstract class in Java with crystal clear definition, purpose with real time example, code, uses and important points. Abstract Class in Java The abstract class is designed to contain both the defined and abstract methods. This class may contain only defined methods OR only abstract methods OR both. NOTE: Recommend reading first, the […]

Static Block in Java

Learn Static Block in java programming with example. A class can have a Static block, where we perform some operations or write some statements, if we want them to call before calling constructor of the class. Here is the static block defined in the class X. Just write the keyword static and put braces {} […]

Static method in Java

Learn static method in java with example i.e. how to write static method in a class and why do we use static methods in application. STATIC METHOD Before explanation, see how we make a method static in a class. It’s simple, just write static keyword before the method. “Call Static methods of a class using […]

Static Variable in Java

Learn Static variables in java with example and how it is different than non-static variables of a class in java programming. For better understanding, we will use static and non static (instance variables) both in example. Static Variables A static variable is shared by all objects of the class. Meaning, static variable has only copy […]

Final Method in Java

Learn final method in java with example and explanation. In a class, we make a method final so that no child class can override and implement it. NOTE: If a class is having final method, it does not mean that the class is also a final class. Purpose of final method is only that it […]

Scroll to top