From 159088d9180e4fcc533cf00b1b310f890e4699a4 Mon Sep 17 00:00:00 2001 From: AbhiramSakha <143825001+AbhiramSakha@users.noreply.github.com> Date: Tue, 17 Mar 2026 19:52:03 +0530 Subject: [PATCH 1/2] feat: add MaximumElement implementation with documentation --- .../thealgorithms/arrays/MaximumElement.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/main/java/com/thealgorithms/arrays/MaximumElement.java 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..7d1d27c6c822 --- /dev/null +++ b/src/main/java/com/thealgorithms/arrays/MaximumElement.java @@ -0,0 +1,25 @@ +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; + } +} From 4f4aa68f3a7eb7b48f502ed2a7c06138dd6c7a9b Mon Sep 17 00:00:00 2001 From: AbhiramSakha <143825001+AbhiramSakha@users.noreply.github.com> Date: Tue, 17 Mar 2026 20:00:26 +0530 Subject: [PATCH 2/2] fix: align MaximumElement with project standards --- .../com/thealgorithms/arrays/MaximumElement.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/thealgorithms/arrays/MaximumElement.java b/src/main/java/com/thealgorithms/arrays/MaximumElement.java index 7d1d27c6c822..886aa271225b 100644 --- a/src/main/java/com/thealgorithms/arrays/MaximumElement.java +++ b/src/main/java/com/thealgorithms/arrays/MaximumElement.java @@ -1,17 +1,21 @@ package com.thealgorithms.arrays; /** - * This class provides a method to find the maximum element in an array. + * Finds the maximum element in an array. */ -public class MaximumElement { +public final class MaximumElement { + + private MaximumElement() { + // utility class + } /** - * Finds the maximum value in the given array. + * Returns the maximum element in the array. * - * @param arr the input array - * @return the maximum element in the array + * @param arr input array + * @return maximum value */ - public static int findMax(int[] arr) { + public static int max(int[] arr) { int max = Integer.MIN_VALUE; for (int num : arr) {