Click here to Skip to main content
15,889,830 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to fix this code to return the minimum value, but i keep getting this error. "Selection does not contain a main type" error in Java Eclipse.



public class MinimumValue{

public static int main(int[] arrayOfInts, int n) {
int currmin = 100;
for (int i = 0; i < n; i++) {
if (arrayOfInts[i] > currmin)
currmin = arrayOfInts[i];
System.out.println(i);
}
return currmin;
}
}

What I have tried:

I tried configuring the build path to point to the correct file but I am still getting this error, any tips?
Posted
Updated 10-Sep-18 21:35pm
Comments
phil.o 10-Sep-18 23:47pm    
Apart from your issue, this code is printing the maximum value (provided that there exists at least a value greater than 100 in the array, otherwise it prints 100), not the minimum.

1 solution

 
Share this answer
 
Comments
CPallini 11-Sep-18 7:18am    
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900