 Hello friends, I am Sanjay Gupta. I welcome you on my channel. You can watch various programming related videos on my channel So you can search it, you can subscribe it. It contains more than 800 videos You can use the keyword programming by Sanjay Gupta on YouTube to watch these videos In this video I am going to demonstrate you how you can write static methods in Java Name of class is static methods Inside this class I am going to define a static method Further that static method will be called in main function Now you can see I am defining a static method whose name is sum Inside this method I am declaring three variables I am assigning values to these variables And then I am going to perform addition operation So this is for just demonstration purpose I am not reading values from user, I am just initializing them at my own And then I am going to display the sum on output screen So this way I have defined a static method So this will be known as static method So static method has spatial capability That if a particular class is having a static method Then you don't need to create its object You can directly call that static method inside that class in another method And it is also possible that you have two different classes So if first class is having static method and you want to call it into another class Then you have to use name of class also Right now I am using this static method inside this single class My second method is main Now inside this main method I am going to call sum method So this way I am calling this static method So first main method will be called And after calling of main, main will be calling sum method So because sum is static method So there is no requirement to create object of this class You can directly call it So first I am going to run this code Then I will demonstrate you how you can use static method of another class into another class So we will be defining two different classes You can see here code is working properly It is printing sum equals to 30 on output screen So friends, this way you can simply create static methods in a particular class And you can call them into another methods Now I am going to cut this code from here And I am creating another class And inside this class I am pasting this method So first class is static In this class I have static method whose name is sum Then this class ends here at line number 12 Then I have another class whose name is static methods Which is containing main Now here I have to use test static dot sum So this way I can directly call methods of a particular class And that method must be static Because static method can be called with the name of class You don't have to create objects If you create objects then also you can call those methods But you can directly do it like this So I am saving this code From here I have to remove public Because there is a rule in a particular file You can have only one public class I have used two public classes That's why it is showing an error So you can see it is working properly now also So this way I have demonstrated you two different ways First way was having static method in one class Calling it into another method of same class And second way was there will be two different classes You are calling static method of one class into another class You can also notice that main is also static So it is called by JVA automatically So whenever you want to call a method Without creating object of a particular class Then you can declare that method as static So this is the use of static method in Java I hope you have understood whatever I have demonstrated you in this video If you want to watch more programming related videos You can search the keyword Programming by Sanjay Gupta on YouTube Thank you for watching this video