-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathpeak.java
More file actions
28 lines (23 loc) · 726 Bytes
/
peak.java
File metadata and controls
28 lines (23 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Java Program to find maximum in arr[]
class Test
{
static int arr[] = {10, 324, 45, 90, 9808};
// Method to find maximum in arr[]
static int largest()
{
int i;
// Initialize maximum element
int max = arr[0];
// Traverse array elements from second and
// compare every element with current max
for (i = 1; i < arr.length; i++)
if (arr[i] > max)
max = arr[i];
return max;
}
// Driver method
public static void main(String[] args)
{
System.out.println("Largest in given array is " + largest());
}
}