JUnit
This commit is contained in:
20
DEV2.3/TP02/Ex2/Largest.java
Normal file
20
DEV2.3/TP02/Ex2/Largest.java
Normal file
@@ -0,0 +1,20 @@
|
||||
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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user