Skip to content

Commit 9948af4

Browse files
committed
Solution to find the Maximum Number in an Array
1 parent d63c347 commit 9948af4

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎src/Arrays/MaxValue.java‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package Arrays;
2+
3+
public class MaxValue {
4+
public static void main(String[] args) {
5+
6+
int[] array = {1,2,4563,4,5,6};
7+
System.out.println(getMax(array));
8+
}
9+
10+
static int getMax(int[] array) {
11+
12+
int temp = 0;
13+
for (int i = 0; i < array.length; i ++){
14+
15+
int number = array[i];
16+
if (number > temp){
17+
temp = number;
18+
}
19+
}
20+
return temp;
21+
}
22+
23+
}

0 commit comments

Comments
 (0)