How to write an empty function in Java

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


 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");


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.