How to write an empty function in Java

JavaObject Oriented ProgrammingProgramming

Let us see how to write an empty function in Java −

Example

 Live Demo

import java.util.Vector;
public class Demo{
   public static void my_empty_fun(){
   }
   public static void main(String[] args){
      System.out.println("In the main function");
      my_empty_fun();
   }  
}

Output

In the main function

An empty function is basically creating a function without defining any operations inside it. A class named Demo contains an empty function named ‘my_empty_fun’ which is just completed by placing two flower brackets, without adding any functionality into it. In the main function, a print statement is written after which the empty function is called. Since there is no functionality defined for it, it does nothing.

raja
Published on 07-Jul-2020 08:24:32
Advertisements