0
Can we declare a variable as static final and assign a value to it in the next line?
2 Réponses
+ 3
Yes, but you also need a static block.
For example
public class Program
{
static final String a;
static { a = "a";}
public static void main(String[] args) {
System.out.println(a);
}
}
+ 1
I stand corrected. learn something new everyday :)