當(dāng)前位置:
首頁 >
Demo小细节
發(fā)布時(shí)間:2025/3/15
39
豆豆
(1)
程序如下:
1 public class Example { 2 static int i = 1, j = 2; 3 static { 4 display(i); 5 i = i + j; 6 } 7 8 static void display(int n) { 9 System.out.println(n); 10 } 11 12 public static void main(String[] args) { 13 display(i); 14 } 15 }靜態(tài)的方法只能使用靜態(tài)的屬性
從程序開始的時(shí)候優(yōu)先執(zhí)行static的方法,其次在執(zhí)行main主函數(shù)
轉(zhuǎn)載于:https://www.cnblogs.com/wudidamowang666/p/11073470.html
總結(jié)
- 上一篇: jqgrid下treegrid排序问题
- 下一篇: 研究一下识别验证码,。。。随笔记录