阅读量:104
在Java中,可以使用关键字 static 来定义全局变量数组。下面是一个示例:
public class MyClass {
// 定义全局变量数组
static int[] myArray = {1, 2, 3, 4, 5};
public static void main(String[] args) {
// 访问全局变量数组
for (int i = 0; i < myArray>
在上面的示例中,myArray 是一个全局变量数组,可以在 main 方法中直接访问和使用它。