I have the following code:
package module6;
class ErrorInfo {
String msgs[] = {
"Output Error",
"Input Error",
"Disk Error",
"Index Out-Of-Bounds"
};
int howBad[] = new int[3];
for(int i = 0; i < howBad.length; i++)
howBad[i] = i * 2;
Err getErrorInfo(int i) {
if(i >= 0 & i < msgs.length)
return new Err(msgs[i], howBad[i]);
else
return new Err("Invalid Error Code", 0);
}
}
However, the compiler will not recognize the "for" loop that I have used to intialize my "howBad" array. I get "illegal start of type" error. Can someone shed some light on this error? I do not get it? The "for" loop is pretty fundamental and I have been using it for months. Is there some requirement that it has to be inside a methog or something? Your assistance is appreciated.