So I have this piece of code, the output produced is xycg... but how? Can someone explain in how that is.
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("x");
}
}
I don't even understand how one can write
static{
System.out.print("x");
}
Could this also be explained as well please.
Also The bit where system.out.print("y") is written, how can that be written in it's own block, it's not in the sequence constructor?