Ich sah diesen Beispielcode auf Oracle Certification Website und jemand hier kann mir das Konzept der statischen {} erklären?Java statische Initialisierung Block
public class Sequence {
Sequence() {
System.out.print("c ");
}
{
System.out.print("y ");
}
public static void main(String[] args) {
new Sequence().go();
}
void go() {
System.out.print("g ");
}
static {
System.out.print("* ");
}
}
der 'static' Block wird der erste Block aufgerufen werden, wenn die Klasse kompiliert und ausgeführt wird. Siehe das folgende: http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.7 –
Vielen Dank! – Danilo