I tried to create static object and variable inside the method but i cannot. This same operation is possible outside the method. Please help me anyone.
Class Sample()
{
}
class Example
{
void Mark()
{
static int i=100; //Error, only final is allowed
Static Sample s=new Sample();// Error, only final is allowed
System.out.println(i);
}
}
public class StaticObject
{
public static void main(String[] args)
{
Example e=new Example();
e.Mark();
}
}