what does static do on a function in java code example
Example 1: static in java
static keyword is a non-access modifier. static keyword can be used with
class level variable, block, method and inner class or nested class.
Example 2: Static method in java
We can declare a method as static by adding keyword “static” before method name.
Let’s see example on static method in java.
public class StaticMethodExample
{
static void print()
{
System.out.println("in static method.");
}
public static void main(String[] args)
{
StaticMethodExample.print();
}
}