They are equivalent. In fact, if you compile these two, you will see that they generate exactly the same bytecode:
Publisher();
Code:
0: aload_0
1: invokespecial #1; //Method java/lang/Object."<init>":()V
4: aload_0
5: new #2; //class java/util/ArrayList
8: dup
9: invokespecial #3; //Method java/util/ArrayList."<init>":()V
12: putfield #4; //Field observers:Ljava/util/ArrayList;
15: return
}
Given that they are the same code, there obviously cannot be any difference in speed :)
Please note that in C # they are not completely equivalent - in C # the initializer for observerswill be executed before the base constructor is called; in Java they are really the same.
, . , , . , , , "" , .