什么是"This array-name does not have a '[' behind it "?


class Input{
static char[] InputALine( String c ) throws Throwable{
char []sLine = new char[100];
if(c.equlas("a")){
int i = 0 ;
sIn = G.sIn.ReadChar();
while ( sIn != '.' ) {
sLine[i] = sIn;
i++;
sIn = G.sIn.ReadChar();
}
}
return sLine; <-- problem
}
}

错误:

sLine
This array-name does not have a '[' behind it 

我是Java的新手,我使用return sLinereturn sLine[]

它仍然不起作用。我想从输入ALine( .. ( 返回字符数组

我不知道发生了什么。

你应该写:

char[] sLine = new char[100];

而不是

char []sLine = new char[100];

你应该使用一个空格来分隔 [] 和变量名,否则整个事情 ([]sLine( 将被视为变量名

相关内容

最新更新