Your strBlock
variable is a local variables within the static initializer block. Its scope is limited to that block, just like any other local variable. If you want to be able to access it in the main
method, you’ll need to declare it as a field:
static strBlock; // Static field declaration
static {
// Static field initialization
strBlock = "Initialized in a static block";
}
solved Static block + cannot find symbol [duplicate]