{}
62
%OFF

Stop copy pasting code you don't actually understand

Build the coding confidence you need to become a developer companies will fight for

Stop copy pasting code you don't actually understand

Become a PRO
Become a PRO
62
%OFF

Stop copy pasting code you don't actually understand

Build the coding confidence you need to become a developer companies will fight for

Stop copy pasting code you don't actually understand

Become a PRO
Become a PRO
run-icon
Main.java
import java.util.Scanner; class HelloWorld { public static void main(String[] args) { Scanner sc =new Scanner(System.in); int j=0; int[] arr={12,13,5,67,8}; int mx=Integer.MIN_VALUE; for(int i=0; i<arr.length; i++){ if(arr[i]>mx){ mx=arr[i]; j=i; } } int smx=Integer.MIN_VALUE; for(int i=0; i<arr.length; i++){ if(arr[i]>smx && i!=j) smx=arr[i]; } System.out.println("mx is="+mx); System.out.println("smx is="+smx); } }
Output