java - 我不知道 Eclipse 中的数组发生了什么

标签 java arrays eclipse syntax

我在 Eclipse 中编写数组时遇到问题:

public class nizovi {
    int[] anArray;
    anArray = new int[10];

}

Eclipse 说:

"Syntax error on token ";" ,, expected"

正如您所看到的,它看起来非常好。我不知道这是怎么回事。

最佳答案

如果要在类级别分配值,则必须在一行中完成:

public class nizovi {
    int[] anArray = new int[10];

}

关于java - 我不知道 Eclipse 中的数组发生了什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38225729/

相关文章:

c - 列出c中数组的数字内容

java - 尝试使用compareTo()对数组进行排序但出现错误

eclipse - 开始使用 IDE?

java - Spring RestTemplate + 将 XML 结果映射到 Domain 对象

java - SMTP 和 Java 电子邮件错误

java - 使用 Z3 的 Java 中的段错误

java构建路径问题

java - 在 Geotools 中构建 Shapefile 时遇到问题

javascript - 如果内部数组满足条件,则删除外部数组对象

android - 无法在 AVD 中创建模拟器