Hello there. I was looking around this site, and saw the following code from a previous thread:
class A{
static{
int x = 5;
}
static int x,y;
public static void main(String args){
doStuff();
System.out.println(y++ + x + ++x);
}
static void doStuff(){
x++;
++y;
}
}
But I didn�t understand this part:
static{
int x = 5;
}
what�s that? It isn�t a constructor, and not a method, and no inner class. So what can it be?
Thanks.
class A{
static{
int x = 5;
}
static int x,y;
public static void main(String args){
doStuff();
System.out.println(y++ + x + ++x);
}
static void doStuff(){
x++;
++y;
}
}
But I didn�t understand this part:
static{
int x = 5;
}
what�s that? It isn�t a constructor, and not a method, and no inner class. So what can it be?
Thanks.