public static void main(String[] args) {

int[] nums = {3,2,1,5,6,4};

int k=2;

```
int output =findKthLargest(nums,k);
System.out.println("Output is :"+output);
}
```

public static int findKthLargest(int[] nums, int k) {

```
for (int i = 0; i < nums.length; i++) {
for (int j = i + 1; j < nums.length; j++) {
if (nums[j] > nums[i]) {
int temp = nums[i];
nums[i] = nums[j];
nums[j] = temp;
}
}
}
for (int x = 0; x < nums.length; x++) {
System.out.println(nums[x]);
}
return nums[k - 1];
}
```

Output is 5.