-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask.java
More file actions
31 lines (25 loc) · 794 Bytes
/
Copy pathtask.java
File metadata and controls
31 lines (25 loc) · 794 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
29
30
31
public class task {
public static void main(String[] args) {
// int[] arr = new int[] { 1, 3, 2, 5, 8, 7, 9 };
// System.out.println("Largest number in the array is : " + Largest(arr));
// System.out.println("Smallest number in the array is : " + Smallest(arr));
}
public static int Largest(int[] arr) {
int max = arr[0];
for (int i = 1; i < arr.length; i++) {
if (arr[i] > max) {
max = arr[i];
}
}
return max;
}
public static int Smallest(int[] arr) {
int small = arr[0];
for (int i = 0; i < arr.length; i++) {
if (arr[i] < small) {
small = arr[i];
}
}
return small;
}
}