diff --git a/src/main/java/com/thealgorithms/arrays/MaximumElement.java b/src/main/java/com/thealgorithms/arrays/MaximumElement.java new file mode 100644 index 000000000000..4ac863fe5470 --- /dev/null +++ b/src/main/java/com/thealgorithms/arrays/MaximumElement.java @@ -0,0 +1,26 @@ +package com.thealgorithms.arrays; + + +/** + * This class provides a method to find the maximum element in an array. + */ +public class MaximumElement { + + /** + * Finds the maximum value in the given array. + * + * @param arr the input array + * @return the maximum element in the array + */ + public static int findMax(int[] arr) { + int max = Integer.MIN_VALUE; + + for (int num : arr) { + if (num > max) { + max = num; + } + } + + return max; + } +}