Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/main/java/com/thealgorithms/arrays/MaximumElement.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
Loading