+ 3
How to print second highest in unsorted int array?
5 Answers
+ 11
luka nailed it!
+ 1
Store values into two variables...
int first = -1;
int second = -1;
int[] nums; // ... len random items from 0 to N
for(int i = 0; i < len; i++) {
   if(nums[i] > first) {
      second = first;
      first = nums[i];
   }
   else if(nums[i] > second)
      second = nums[i];
}
+ 1
public class Program
{
    public static void main(String[] args) 
    { 
    int high=0,secondhigh=0;
    
    
    int[] ar= {6,2,4,9,3,8};
    
    Arrays.sort(ar);//sorting
    
    for(int n:ar)
    {
//System.out.print(n);//sorted array
    }
        high=ar[ar.lenght-1];
              System.out.print("high "+high );
       secondhigh=ar[ar.lenght-2];
       
 
       System.out.print("secondhigh "+secondhigh);
        
    }
}
0
i cnt understand ths plzz say clearly abt multidimensional array



