Skip to content

Commit 9d705e0

Browse files
committed
largest number in array
1 parent 4873e18 commit 9d705e0

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.dev.arrayandhashing;
2+
3+
public class LargestNumberInArray {
4+
5+
public static int getLargestNumberIn(int [] arr){
6+
int max = arr[0];
7+
8+
for (int i = 0; i < arr.length; i++) {
9+
if (arr[i] > max)
10+
max = arr[i];
11+
}
12+
return max;
13+
}
14+
15+
public static void main(String[] args) {
16+
17+
int[] numbers = {1,2, 523,1, 5546, 24, 10000, -1};
18+
19+
int largestNumberIn = getLargestNumberIn(numbers);
20+
System.out.println("largestNumberIn = " + largestNumberIn);
21+
22+
}
23+
}

0 commit comments

Comments
 (0)