posted 4 years ago
Neither. Both are dangerous bits of code because you have public non‑final fields. You are using global variables, which can be error‑prone because the class has no control over those values.
1: You can use a static initialiser. 2: You can initialise in situ. 3: Both have the same effect. Use whichever you think is easier to read. 4: You sometimes need a static initialiser, as code below. 5: I suggest you use only one initialiser, because you can get confused about execution order.