Dear Amir
static block in a class will be executed first when the class is loaded
so when normally people use static block to initialize some their variables
so for you to understand better try this program!!!
class teststatic
{
static
{int x=10;
y=100;
}
static int x;
// Initialize a value and check what happens
static int y;
public static void main(
String[] args)
{ System.out.println(x); //#5
System.out.println(y); //#6
//teststatic t1= new teststatic(); //#7
//System.out.println(x);
//System.out.println(y);
} }
So in static block if u declare an int x and intialiaze it to 10 nothing wrong is there
but the only thing is that the scope of the varial int x will be only inside the static block!!!
but if u have declared static int y and initialize this y inside the static block , it's scope is through out that class
and for your question there will not be any multiple declaration erros as int x is only inside static block and static int x will be through out the class
hope this might help you