Java??static???????ú??÷?????
???????????? ???????[ 2017/2/13 9:40:56 ] ??????????????????? Java
????static???“???”????“???”??????????????γ??????????????????????γ???static????飬????Java???????????????????
??????static???ε??????????????????????????κζ??????????????????????????????????????????????
????????????????Java?????????????????????????????????????????????????static??????????????κζ?????????????????????κζ???
??????public???ε?static????????????????????????????????????????????????????У???????static?????????????????????????????????static??????
????static???????????private???Σ????????????????????????????У?????????????????????????????????????????????????????–?????????????????????????????????????????????????????????????????????private?????????????static??????????????????????????????????static??????????????????????Ч???????????
????static???ε?????????????????????????????????????????????????????????????????????
????????.?????????(?????б?…)
????????.?????????
??????static???ε??????????????飬??Java???????JVM???????????????и????饗??????????????
????1??static????
??????????????????????????з????????????????static???ε???????о????????????????????????б?static???ε?????????????????
????????????????
??????????????????????????????????????棩??JVM??????????????棬??????????????????????????????????????????????????????????????????????????????????????????
?????????????????????????????????????????????????棬???????????????????ж????????????????????
??????????????????????????????????t????????
???????????乲????
???????????????
????2?????????
???????????????????????????????κε???????????????
??????????????в?????this??super???????????????????????????????????????(?????static???????????????????)??????????????????????????????????
???????????????????????????????????????????????е????????????????
???????static???????????κ?????????static????????????????????????abstract??
??????????????????????Java API?е?Math???????е?????????????????????????static?????????????????÷???????á?
?????????????????????????????????????????????????????????????????????????????????????
????3??static?????
????static???????о??????飬???????ж???????????static???飬?????ж????λ?????????????????κε?????????JVM??????????????Щ????????飬???static??????ж????JVM???????????????г??????????????????????????????????????Ρ????磺
????public class Test5 {
????private static int a;
????private int b;
????static{
????Test5.a=3;
????System.out.println(a);
????Test5 t=new Test5();
????t.f();
????t.b=1000;
????System.out.println(t.b);
????}
????static{
????Test5.a=4;
????System.out.println(a);
????}
????public static void main(String[] args) {
????// TODO ?????????????
????}
????static{
????Test5.a=5;
????System.out.println(a);
????}
????public void f(){
????System.out.println("hhahhahah");
????}
????}
???????н??
????3
????hhahhahah
????1000
????4
????5
????4??static??final?????????
????static final???????γ???????????????????????“??????”??
?????????????????????????????????????????????????
?????????????????????????????????????????????
???????????????????????????????????????????????κζ??????????£????????????????????????????????????????????????????????????????????????????????????????????????????????static(?????)???????????????????????????????static?????????????????κζ?????????????????????????κζ?????????????????????????static??static ????????????????main( ) ??????????????????????main() ???????????????static??
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11