基本上,我试图在另一个类中调用一个方法,但我遇到了错误。
以下是代码:
public class Ocean
{
private static int gridWidth, gridHeight;
private int safeCount;
private boolean shipSafe;
private static Ship[] ships;
private static int[][] grids;
public Ocean(int a, int b, int c)
{
grids = new int[a][b];
ships = new Ship[c];
for(int i = 0; i < c; i++)
{
ships[i] = Ship();
}
gridWidth = a;
gridHeight = b;
}
我无法访问公共Ship类,错误显示在ships[i] = Ship();
中
我尝试重新定义它,添加了一个构造函数。
答案 0 :(得分:0)
更改line ships [i] = new Ship();