Java Design Pattern
Introduction to Java 10
Introduction to Java 11
Introduction to Java 12

JAVA Static Method

  • • 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 com.silan;
class Test
{
	  static int x;
	  static void get()
	  {
			x=100;
			System.out.println("x="+x);
	  }	 
}
public class StaticExample2 {

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

Output


static variable

About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.


We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc







 PreviousNext