Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.javatechie.solution;
- public class Array_Max_Min {
- public static void main(String[] args) {
- int[] num = { 90, 24, 46, 35, 32, 12, 98, 2 };
- int max = num[0];
- int min = num[1];
- for (int i = 0; i < num.length; i++) {
- if (num[i] > max) {
- max = num[i];
- } else if (num[i] < min) {
- min = num[i];
- }
- }
- System.out.println("Max Element is " + max);
- System.out.println("Min Element is " + min);
- }
- }
Add Comment
Please, Sign In to add comment