Studying Java I came across the following code:
static {
System.out.println("bloco estático inicializado");
}
Then I ended up calling the main
method and the block was executed. How does this happen? I know that a static
method does not need the instance of an object to refer to it, but we need to at least call them by name. I do not quite understand why the block runs.