{}
BLACK NOVEMBER
Get 83% off PRO
Are you struggling to build your coding confidence or land your first job?
Fast-track to your first pay-check.
Start FREE trial →
Start FREE trial →
BLACK NOVEMBER
Get 83% off PRO
Are you struggling to build your coding confidence or land your first job?
Fast-track to your first pay-check.
Start FREE trial →
Start FREE trial →
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