我对下面的代码有一些问题。我正在使用InputSreamReader
,接收输入BufferReader
。我收到一条错误消息,指出。
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Illegal modifier for parameter findMin; only final is permitted
Syntax error on token "(", ; expected
Syntax error on token ",", ; expected
Syntax error on token ",", ; expected
Syntax error on token ")", ; expected
请记住,代码尚未完成>我只是想确定我缺少什么以使此错误消失。
public static void main(String[] args) throws IOException
{
double [] numbers = new double[100];
InputStreamReader streamR = new InputStreamReader(System.in);
BufferedReader inFile = new BufferedReader(streamR);
String reader = inFile.readLine();
/ / This method finds the smallest number in an array looking at indexes startIndex and endIndex
public static double findMin(double[] elements, int startIndex, int endIndex)
{
if (endIndex == startIndex) // base case
{
return elements[endIndex];
}
else // recursive case to compare the min found so far
{
double previousMin = findMin(elements, startIndex, endIndex-1);
if (previousMin > elements[endIndex])
return elements[endIndex];
else
return previousMin;
}
}