Is there a solution to use a final variable in a Java constructor? The problem is that if I initialize a final field like:
private final String name = \"a na
I do not really understand your question. That
public class Test3 { private final String test = "test123"; public Test3() { System.out.println("Test = "+test); } public static void main(String[] args) { Test3 t = new Test3(); } }
executes as follows:
$ javac Test3.java && java Test3 Test = test123