Files
DEV/DEV2.3/TP02/Ex2/Largest.java
Simoes Lukas c16ef0985f JUnit
2025-05-26 12:07:58 +02:00

20 lines
440 B
Java

public class Largest {
/**
* Return the largest element in a list.
*
* @param list A list of integers
* @return The largest number in the given list
* @throws NullPointerException si le tableau est null
*/
public static int largest(int[] list) {
int max = list[0];
for (int index = 0; index <= list.length-1; index++) {
if (list[index] > max) {
max = list[index];
}
}
return max;
}
}