This commit is contained in:
Tim Tersch
2020-08-27 10:59:35 +02:00
parent bed254d9a4
commit cb25a9c820

View File

@@ -123,7 +123,16 @@ public class Arrays {
* Für ein leeres Array wird 0 zurück gegeben.
*/
public int max( int[] pArray ) {
return 0;
if (pArray == null || pArray.length == 0) {
return 0;
}
int max = pArray[0];
for (int i = 0 ; i < pArray.length; i++) {
if (pArray[i] > max) {
max = pArray[i];
}
}
return max;
}
/**