Static methods are as close as possible to a global method. so why is this type of method call not possible? is there any other way to call the static method without instantiating the class??
import java.io.*;
import java.util.*;
class pgm
{
int x,v;
static void func()
{
System.out.println("Function run");
}
}
class egs
{
public static void main(String args[])
{
pgm p=null;
pgm.func();
try
{
p.x=10;
p.func();
}
catch(NullPointerException e)
{
e.printStackTrace();
}
}
}