Created
April 25, 2014 10:46
-
-
Save kurogelee/11285273 to your computer and use it in GitHub Desktop.
インスタンスイニシャライザ実行とフィールド初期化はどっちが先に? ref: http://qiita.com/kurogelee/items/09e5270385d14148f5e8
This file contains hidden or 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
field1 | |
initializer1 | |
field2 | |
initializer2 | |
constructor |
This file contains hidden or 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 basic; | |
import java.util.function.*; | |
public class Init { | |
Init(){ | |
p("constructor"); | |
} | |
int i = ((IntSupplier)(() -> { p("field1"); return 0; })).getAsInt(); | |
{ | |
p("initializer1"); | |
} | |
int j = ((IntSupplier)(() -> { p("field2"); return 0; })).getAsInt(); | |
{ | |
p("initializer2"); | |
} | |
static void p(String s){ | |
System.out.println(s); | |
} | |
public static void main(String... args){ | |
new Init(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment