package cn.hew.demo01;
public class Person {
static int arr[] = new int[10];// 输出为0
// int arr[] = new int[10]; //编译时报错
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(arr[1]);
}
}
/*
*第一眼看到会认为考察 数组中的值默认被赋值为0
*但是, Sysout.out.println(arr[1]);在main函数当中.所以需要静态的数组
*Cannot make a static reference to the non-static field arr
*/
007关于静态方法的代码分析问题
最新推荐文章于 2022-04-19 19:08:13 发布