gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 18:04:01 25 4
gpt4 key购买 nike

我在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com