---
# System prepended metadata

title: Anshuman Sharma

---

# Anshuman Sharma

# Question 1: Find the 2nd largest number in an integer array. 
```java=
// logic. 



[1,4,5,7,8,0,-1,-2]

public static int secLargest(int arr[]) {
    
    int largerst = arr[0];
    int sec = arr[0];
    
    for(int i = 1; i < arr.length; i++) {
        if(arr[i] > largest) {
            sec = largest;
            largest = arr[i];
        }
    }
}

System.out.println(sec);




```