0

我正在尝试通过类的构造函数将二维字符数组复制到另一个二维字符数组中。原始数组从外部文本文件中读取,然后转换为二维数组。但是我似乎无法从另一个类中读取这个二维数组。下面列出了我正在尝试的代码,它是搜索类的构造函数。谢谢你。

char[][] arraytwo;

public search(char[][] inarray)
{
    for(int i = 0; i < inarray.length; i++)
    {
        String row = inarray.;
        for(int j = 0; j < inarray[i].length; j++)
        {
            arraytwo[i][j] = inarray.charAt(c);
        }
    }
}
4

2 回答 2

1

The statement inside your inner for loop should be:

arraytwo[i][j] = inarray[i][j];

You index an array using the same syntax whether you're reading from it or writing to it. (charAt is a method you'd call on a String, not an array.)


Also, you don't need the line

String row = inarray.;

There's a syntax error on that line anyway.

于 2014-04-07T00:28:23.943 回答
0

the code is malformed, you copied that wrong:

String row = inarray.;
于 2014-04-07T00:29:52.330 回答