Hi,
Can anybody clearly explain me that what is executed first? A Static block, a static method or static variables? What is sequence of execution of these following lines?
public class Static
{
static
{
int x = 5;
}
static int x,y;
public static void main(
String args[])
{
x--; myMethod();
System.out.println(x + y + ++x);
}
public static void myMethod()
{
y = x++ + ++x;
}
}
What will be the output? If you move the statis block below the static variable decalaration, why the output remains same.....
Please reply as soon as possible.
Dipti