Created
April 1, 2012 03:31
-
-
Save ajduke/2270978 to your computer and use it in GitHub Desktop.
Initializing Final variables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ajd.examples.basics; | |
public class FinalVariable { | |
final int finalInstanceField | |
// =5 | |
; | |
static final int finalStaticField = 5; | |
{ | |
// finalField = 5; | |
} | |
static { | |
// finalStaticField = 7; | |
} | |
public FinalVariable() { | |
finalInstanceField = 7; | |
// finalStaticField=5; | |
} | |
public static void main(String[] args) { | |
final int a = 0 ; | |
System.out.println(a); | |
System.out.println(finalStaticField); | |
System.out.println(new FinalVariable().finalInstanceField); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment