static object method java code example

Example 1: java what is static

In the Java programming language, the keyword static indicates that the particular member belongs to a type itself,
rather than to an instance of that type.
This means that only one instance of that static member is created which is shared across all instances of the class.

Example 2: how to call a static method in java

class scratch{
	public static hey(){
		System.out.println("Hey");
    }
	public static void main(String[] args){
		hey();
        //print Hey to the console
    }

Example 3: how to call a static method from another class in java

// Called from outside the MyUtils class.
double avgAtt = MyUtils.mean(attendance);

Tags:

Misc Example