Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature may not be available in some browsers.
Die Warnmeldungen beziehen sich (wohl) auf "this method must return a result of type int" oder "dead code" (o.s.ä.). Mit einer Änderung im Code geht es (auch mit Eclipse):kleinsten Wert
public class A1_Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
int a [] = {2,-2,-3,1,-9};
System.out.println(findSmall(a));
//System.out.println(findSmall_alt(a)); //Implementierung aus dem Screenshot, wohl nicht zuverlässig
}
public static int findSmall ( int a []) {
int min=a[0];
for(int i=0; i < a.length; i++) {
if(a[i]<min) {
min=a[i];
}
}
return min;
//}
}
/*
public static int findSmall_alt ( int a []) {
int min=a[0]; //ansonsten Warnmeldung "may not have been initialized"
for(int i=0; i < a.length; i++) {
for ( int j=i+1; j< a.length-1; j++) {
if(a[i]<a[j]) {
min=a[i];
}
}
}
return min;
}
*/
}