su4sml/su4sml/add-ons/jtestdataaccessor/src/main/java/ch/ethz/infsec/jtestdataaccessor/examples/IntMax.java

17 lines
297 B
Java
Raw Normal View History

package ch.ethz.infsec.jtestdataaccessor.examples;
public class IntMax {
public static int max(int[] array) throws Exception {
int max = 0;
for(int i : array){
if(i < 0){
throw new Exception("Negative element detected.");
}
if(i > max){
max = i;
}
}
return max;
}
}