84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
private static String name = "demo";
private static String name; static { name = "demo"; }
As shown in the above code, what is the difference between the two writing methods, or what are the advantages and disadvantages of each.
拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...
There is no difference as far as the intermediate code is concerned
There is no difference in the result, but you can write other code in the code block, such as stuffing data into the map.
In the static code block, you can assign values to more variables and other operations. It is generally used for initialization, such as loading static resource images when the game is loaded.
There is a small difference: in the same class, the initialization of static properties is completed before the static initialization block
There is no difference as far as the intermediate code is concerned
There is no difference in the result, but you can write other code in the code block, such as stuffing data into the map.
In the static code block, you can assign values to more variables and other operations. It is generally used for initialization, such as loading static resource images when the game is loaded.
There is a small difference: in the same class, the initialization of static properties is completed before the static initialization block