Good day. I need to initialize the static final variable, I do it in a static initialization block. The point is that the initialization of the variable itself can throw an exception, I wrapped the initialization in try {} catch, but then the compiler tells me that the variable may not be initialized, it is correct, but then how can I initialize this variable? Here is how the code example:
public class Example { public static final Connection connection; static { try { connection = DriverManager.getConnection("jdbc:sqlite:" + PATH); //Вот эта строка может выкинуть исключительную ситуацию } catch (Exception ignored) {} } }
connection = null;- Igor