• Like static variable, method can be declared as static which is called as static method.
  • Static method is a class level concept, that means static method directly invoked by class.
  • Static method can access only static data.

 

Example;
package java8s;

class Test
{
      static int x;
      static void get()
      {
            x=100;
            System.out.println("x="+x);
      }
     
}

public class StaticExample1 {

      public static void main(String[] args) {
           
            Test.get();

      }

}

Output


static method

Our Services:

Java Training | Python Training | Machine Learning with Python Training | Deep Learning with Python Training | Data Science with Python Training | Projects

SILAN Technology, BBSR
Call to: 0674-2361252

Comment