Skip to content

Commit 159088d

Browse files
authored
feat: add MaximumElement implementation with documentation
1 parent 7d57c57 commit 159088d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.thealgorithms.arrays;
2+
3+
/**
4+
* This class provides a method to find the maximum element in an array.
5+
*/
6+
public class MaximumElement {
7+
8+
/**
9+
* Finds the maximum value in the given array.
10+
*
11+
* @param arr the input array
12+
* @return the maximum element in the array
13+
*/
14+
public static int findMax(int[] arr) {
15+
int max = Integer.MIN_VALUE;
16+
17+
for (int num : arr) {
18+
if (num > max) {
19+
max = num;
20+
}
21+
}
22+
23+
return max;
24+
}
25+
}

0 commit comments

Comments
 (0)