Preview:
import java.util.Arrays; // Import required for Arrays utility class

class Main {
    public static void main(String[] args) {
        int arr[] = {1, 3, 2, 6, 5, 4}; // Correct array initialization
        Arrays.sort(arr); // Correct usage of Arrays.sort
       System.out.println(Arrays.toString(arr)); // prints the  sorted array
       int n = arr.length;
       System.out.println(arr[n-1]);

       
    }
}
//Tc-O(nlogn)
//lergest element in an array ( sorting and return n-1) (brute force method)
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter