public static void main(String[] args) { int [] arr = {100,200,300,50,40,-10,-50}; int max = Integer.MIN_VALUE; for(int each: arr) if(each > max) max = each; System.out.println(max); // 300