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 … Read more how to measure method execution time in java

User Defined Exception in Java with Real-time example

User Defined Exception in Java with a real-life example and code. You’ll learn how to use this exception in a class. User defined exception means you write your own custom exception class to use in a program. If an exception occurs, it throws the exception. You can use your custom message to show to the … Read more User Defined Exception in Java with Real-time example

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 … Read more Abstract Class in Java with Purpose and Real Time Example

Java: Abstract method in Easy Way with Real-Time Examples

Learn the abstract method in Java, clear definition, Where to Use and why to use in a program with super simple real-time examples. What is an Abstract method in Java? A method that has only a declaration and no implementation (no body) is known as an abstract method. The keyword “abstract” is used in a … Read more Java: Abstract method in Easy Way with Real-Time Examples

Issue Of Not Using Abstraction In Java And Its Solution

See the issue when you don’t use abstraction concept in java and its solution with a program example and explanation. First, we will create a program in which abstraction is not applied and discuss the problem because of it. The, we will see the solution of the problem with same program example by applying abstraction. … Read more Issue Of Not Using Abstraction In Java And Its Solution

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. class Utility { //static method public static … Read more Static method in Java

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 … Read more Static Variable in Java