We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7d57c57 commit 159088dCopy full SHA for 159088d
src/main/java/com/thealgorithms/arrays/MaximumElement.java
@@ -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