statick keyword in java code example
Example 1: static keyword in java
// 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();
}
}
Example 2: static keyword in java
// example on static class in java.
import java.util.*;
public class OuterClass
{
// static class
static class NestedClass
{
public void show()
{
System.out.println("in static class");
}
}
public static void main(String args[])
{
OuterClass.NestedClass obj = new OuterClass.NestedClass();
obj.show();
}
}