0
基本上,我試圖在另一個類中調用一個方法,但我遇到了錯誤。訪問另一個類的公共方法
這裏是代碼:
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;
}
我無法訪問公共船級,並出現在ships[i] = Ship();
我試圖重新定義它的錯誤,添加一個構造函數。
請格式化代碼,並添加一個語言標籤(也許是Java?) – Thilo 2014-12-06 02:57:12