I\'m looking at the code below and found something a bit strange:
public class Sequence {
Sequence() {
System.out.print(\"c \");
}
{
static {
System.out.print("x ");
}
is an initialization block shared by the class(as indicated by static), which is executed first.
{
System.out.print("y ");
}
is an initialization block shared by all objects(constructors) of the class, which comes next.
Sequence() {
System.out.print("c ");
}
is a particular constructor for the class, which is executed third. The instance initialization block is invoked first every time the constructor is executed. That's why "y" comes just before "c".
void go() {
System.out.print("g ");
}
is just an instance method associated with objects constructed using the constructor above, which comes last.