CodesJava

Easy learning with example program codes

what is static method in java?


Static methods

Static methods represent the behavior of whole class. An instance of a class is not required to execute static methods. They can be called using class name.
Syntax: ClassName.methodName

Example

/**
 * This program is used to show that there is no need of an object
 * for accessing a static method. It can be called with class name.
 * @author CodesJava
 */
class Display {
	//static method
	public static void display(){
		System.out.println("Hello codesjava.com");
	}
}
public class StaticExample4 {
	public static void main(String args[]){
		//No need for object to call static method.
		Display.display();
	}
}

Output

Hello codesjava.com
Sign Up/ Sign In
Ask a Question


Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at hr@codesjava.com.

Development

We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on hr@codesjava.com.

Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki